aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-02-24 09:37:19 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-02-24 09:37:19 +0100
commit2ca318116c6ad8a539dd13d86475add4548c5524 (patch)
treea33d751ea12d8cb4b3769e0210f380ab7ff6a972 /vis.c
parent0fc532329cbd9b287e2e7bdc0d837348d0a2a703 (diff)
downloadvis-2ca318116c6ad8a539dd13d86475add4548c5524.tar.gz
vis-2ca318116c6ad8a539dd13d86475add4548c5524.tar.xz
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 (limited to 'vis.c')
-rw-r--r--vis.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/vis.c b/vis.c
index aaead35..303a5e6 100644
--- 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);