aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-10-31 14:26:33 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-10-31 14:26:33 +0100
commitb6f287938aecc060e8651dba8c77909616ff245b (patch)
tree856f436f91970ddb4931bf455801dfaf1e214743
parent3cbea071e181cd3fa1bd77be0ec586cf41735e60 (diff)
downloadvis-b6f287938aecc060e8651dba8c77909616ff245b.tar.gz
vis-b6f287938aecc060e8651dba8c77909616ff245b.tar.xz
view: make zb command more robust
The new approach first scrolls the window up such that the current cursor line lies below the current visible area, then the viewport is adjusted until the line is once again visible (at the bottom of the window). Closes #85
-rw-r--r--view.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/view.c b/view.c
index e7f9d4d..0491c78 100644
--- a/view.c
+++ b/view.c
@@ -707,11 +707,9 @@ void view_redraw_bottom(View *view) {
Line *line = view->cursor->line;
if (line == view->lastline)
return;
- int linenr = 0;
size_t pos = view->cursor->pos;
- for (Line *cur = view->topline; cur && cur != line; cur = cur->next)
- linenr++;
- view_slide_down(view, view->height - linenr - 1);
+ view_viewport_up(view, view->height);
+ while (pos > view->end && view_viewport_down(view, 1));
view_cursor_to(view, pos);
}