On Mon, 14 Jan 2019 21:15:54 +0100, Otto Moerbeek wrote:
> A problem with this diff is that is changes the part of the screen
> shown while switching back and forth between files with Ctrl-^
>
> Normally, vi remembers both the cursor position in the files and the
> part of the file shown (it does recenter in some cases). With this
> diff, it the cursor remains at the correct line, but that part of the
> file shown changes in a differnent way than before.
Good catch. What we really want to set is SC_SCR_CENTER, like
v_init() does. This will still start at the top of a new file.
- todd
Index: usr.bin/vi/vi/vi.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vi.c,v
retrieving revision 1.21
diff -u -p -u -r1.21 vi.c
--- usr.bin/vi/vi/vi.c 18 Apr 2017 01:45:35 -0000 1.21
+++ usr.bin/vi/vi/vi.c 14 Jan 2019 20:50:03 -0000
@@ -395,6 +395,8 @@ intr: CLR_INTERRUPT(sp);
/* If the last command switched files, change focus. */
if (F_ISSET(sp, SC_FSWITCH)) {
F_CLR(sp, SC_FSWITCH);
+ F_CLR(sp, SC_SCR_TOP);
+ F_SET(sp, SC_SCR_CENTER);
(void)sp->gp->scr_rename(sp, sp->frp->name, 1);
}