From 81deff2851c90245d8ed997b68f0e3c4e8ecc123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 28 Feb 2017 16:03:30 +0100 Subject: view: fix display when inserting text at start of file Before cebb24b36ac45cc7c6912481cacd29ef9d5c68b9 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: ifoo --- view.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/view.c b/view.c index 7dcc806..d6a3f3f 100644 --- 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; } -- cgit v1.2.3