vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 03f2fa8855466f178a356feb46a322afd5098303 parent 24df8036ddeec91c438fd3852f6684963b0c59b0 Author: Marc André Tanner <mat@brain-dump.org> Date: Fri, 24 Feb 2017 09:37:19 +0100 vis: fix display after newline insertion at the start of viewport Previously the window content would not be scrolled down when inserting a newline exactly at the start of the display area as in the case when a file starts with an empty line and the following is performed: <PageDown><PageUp><PageUp>o Diffstat:
| M | vis.c | | | 10 | ++++++++-- |
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/vis.c b/vis.c @@ -1486,8 +1486,14 @@ void vis_insert_nl(Vis *vis) { Text *txt = vis->win->file->text; for (Cursor *c = view_cursors(view); c; c = view_cursors_next(c)) { size_t pos = view_cursors_pos(c); - pos = vis_text_insert_nl(vis, txt, pos); - view_cursors_scroll_to(c, pos); + size_t newpos = vis_text_insert_nl(vis, txt, pos); + /* This is a bit of a hack to fix cursor positioning when + * inserting a new line at the start of the view port. + * It has the effect of reseting the mark used by the view + * code to keep track of the start of the visible region. + */ + view_cursors_to(c, pos); + view_cursors_to(c, newpos); } size_t pos = view_cursor_get(view); windows_invalidate(vis, pos, pos-1);