vis

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

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

commit 15cfcbc341fea8ac5b9bb2d9f85422254bd9b87a
parent 3302e5baf745b82a1ac37f08f2f700d325bed753
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Mon,  9 Nov 2015 17:35:16 +0100

view: correctly redraw window content

If a change occured on the very first shown character, it was not
properly reflected in the view.

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

diff --git a/view.c b/view.c @@ -1105,11 +1105,14 @@ void view_cursors_to(Cursor *c, size_t pos) { view->start = pos; view_viewport_up(view, view->height / 2); } else { + /* make sure we redraw changes to the very first character of the window */ + if (view->start == pos) + view->start_last = 0; /* set the start of the viewable region to the start of the line on which * the cursor should be placed. if this line requires more space than * available in the view then simply start displaying text at the new * cursor position */ - for (int i = 0; i < 2 && (pos < view->start || pos > view->end); i++) { + for (int i = 0; i < 2 && (pos <= view->start || pos > view->end); i++) { view->start = i == 0 ? text_line_begin(view->text, pos) : pos; view_draw(view); }