]> git.mdlowis.com Git - projs/tide.git/commitdiff
highlight jumped to line when file opened with address
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 21 Jul 2017 23:39:18 +0000 (19:39 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 21 Jul 2017 23:39:18 +0000 (19:39 -0400)
lib/view.c

index 2232ce8d20f1b30fc3a34ce2a9a5e6b396f70393..5e817e344e80dd48a809d2c55a5e8cc96bf92093 100644 (file)
@@ -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) {