vis

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

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

commit 237b4b21d93f7a06fb638fe3179a22a41296a189
parent 8d56f955dcd500c8ffc72daae2c2de5841d5c60c
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Tue, 28 Feb 2017 16:03:30 +0100

view: fix display when inserting text at start of file

Before 446246abd036f4556485349a76ac5a0def851075 a mark
at the start of the file was treated specially to always
return position zero.

Since this was no longer the case the following would
insert text before the visible area:

 <PageDown><PageUp><PageUp>ifoo

Diffstat:
Mview.c | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/view.c b/view.c @@ -131,9 +131,16 @@ void view_tabwidth_set(View *view, int tabwidth) { static void view_clear(View *view) { memset(view->lines, 0, view->lines_size); if (view->start != view->start_last) { - view->start_mark = text_mark_set(view->text, view->start); + if (view->start == 0) + view->start_mark = EMARK; + else + view->start_mark = text_mark_set(view->text, view->start); } else { - size_t start = text_mark_get(view->text, view->start_mark); + size_t start; + if (view->start_mark == EMARK) + start = 0; + else + start = text_mark_get(view->text, view->start_mark); if (start != EPOS) view->start = start; }