aboutsummaryrefslogtreecommitdiff
path: root/view.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-08-07 22:10:33 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-08-07 22:10:33 +0200
commitee518dc59a5adcc47fa5e56b39da8d347276d1bb (patch)
tree314e58dbeec8dc6bbf052b2cd84a6edab1dddf51 /view.c
parent3bf3d8fe3fb25c2f46eb3d6285fe19590a0aefd7 (diff)
downloadvis-ee518dc59a5adcc47fa5e56b39da8d347276d1bb.tar.gz
vis-ee518dc59a5adcc47fa5e56b39da8d347276d1bb.tar.xz
view: fix screen line based motions when cursor is not visible
If a cursor is not currently visible it has no associated screen line. Fallback to the corresponding logical line based variant. For example `gj` is interpreted as `j`. Fixes #354
Diffstat (limited to 'view.c')
-rw-r--r--view.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/view.c b/view.c
index 33e73cd..2d4730d 100644
--- a/view.c
+++ b/view.c
@@ -772,6 +772,8 @@ size_t view_line_down(Cursor *cursor) {
}
size_t view_screenline_up(Cursor *cursor) {
+ if (!cursor->line)
+ return view_line_up(cursor);
int lastcol = cursor->lastcol;
if (!lastcol)
lastcol = cursor->col;
@@ -784,6 +786,8 @@ size_t view_screenline_up(Cursor *cursor) {
}
size_t view_screenline_down(Cursor *cursor) {
+ if (!cursor->line)
+ return view_line_down(cursor);
int lastcol = cursor->lastcol;
if (!lastcol)
lastcol = cursor->col;