From 81184a1f62cc5fd3554b6c8b910cca0bc26c1db0 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 21 Jul 2017 19:39:18 -0400 Subject: [PATCH] highlight jumped to line when file opened with address --- lib/view.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/view.c b/lib/view.c index 2232ce8..5e817e3 100644 --- a/lib/view.c +++ b/lib/view.c @@ -40,9 +40,12 @@ void view_init(View* view, char* file, void (*errfn)(char*)) { /* load the file and jump to the address returned from the load function */ buf_init(&(view->buffer), errfn); if (file) { - view_jumpto(view, false, buf_load(&(view->buffer), file)); - view_eol(view, false); - view_selctx(view); + size_t pos = buf_load(&(view->buffer), file); + if (pos > 0) { + view_jumpto(view, false, pos); + view_eol(view, false); + view_selctx(view); + } colors_init(view->buffer.path); } } @@ -679,7 +682,6 @@ static void sync_line_numbers(View* view, size_t newpos) { if (view->nrows) view->rows[0]->off = buf_bol(&(view->buffer), newpos); } - } static void apply_colors(View* view) { -- 2.49.0