aboutsummaryrefslogtreecommitdiff
path: root/view.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-02-23 20:45:25 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-02-23 20:45:25 +0100
commit138bc80f5bec0f192cdba189b6ad8920050eb5cf (patch)
tree9e5c9091f419102b8244e1c76131d8ce2954b307 /view.c
parentd42a0df8f1b5e1438f8bb317410b995c8e72efa4 (diff)
downloadvis-138bc80f5bec0f192cdba189b6ad8920050eb5cf.tar.gz
vis-138bc80f5bec0f192cdba189b6ad8920050eb5cf.tar.xz
view: make sure viewport remains valid when scrolling up
In a file with windows style \r\n line endings scrolling up would wrap around to the end of the file.
Diffstat (limited to 'view.c')
-rw-r--r--view.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/view.c b/view.c
index d681656..db9a8a6 100644
--- a/view.c
+++ b/view.c
@@ -664,7 +664,7 @@ bool view_viewport_up(View *view, int n) {
} while (text_iterator_byte_prev(&it, &c));
if (c == '\r')
off++;
- view->start -= off;
+ view->start -= MIN(view->start, off);
view_draw(view);
return true;
}