vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 6a1757c8f6018e5aca607c646591dfcc239e6d9d
parent 69c0cc8ec5b2ebc4e5d12727fa4ac6524e8aab00
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun,  7 Aug 2016 22:10:33 +0200

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:
Mview.c | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git 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;