vis

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

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

commit 4b38257d7dcc10504808700a914cbe09ac3d018c
parent 0278f15e7421d61dc1b5aa1dc8cd613b033c8848
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Mon,  5 Dec 2016 23:11:10 +0100

view: make cursor placement more robust

Reject invalid cursor positions.

Diffstat:
Mview.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/view.c b/view.c @@ -1164,6 +1164,11 @@ void view_cursors_scroll_to(Cursor *c, size_t pos) { void view_cursors_to(Cursor *c, size_t pos) { View *view = c->view; + if (pos == EPOS) + return; + size_t size = text_size(view->text); + if (pos > size) + pos = size; if (c->view->cursor == c) { /* make sure we redraw changes to the very first character of the window */ if (view->start == pos)