tex: edit command for non-existent files - neatvi - [fork] simple vi-type editor with UTF-8 support
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit 24a8fe7457134dd4423c4700bf715077b5f26df4
parent 390adf97095970215ad4f23c3288ec3e2d374e11
Author: Ali Gholami Rudi 
Date:   Thu, 14 May 2015 15:52:25 +0430

ex: edit command for non-existent files

Diffstat:
  M ex.c                                |       6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/ex.c b/ex.c
t@@ -192,13 +192,13 @@ static void ec_edit(char *ec)
         int fd;
         ex_arg(ec, arg);
         fd = open(arg, O_RDONLY);
+        lbuf_rm(xb, 0, lbuf_len(xb));
         if (fd >= 0) {
-                lbuf_rm(xb, 0, lbuf_len(xb));
                 lbuf_rd(xb, fd, 0);
-                lbuf_undofree(xb);
                 close(fd);
-                xrow = MAX(0, lbuf_len(xb) - 1);
         }
+        xrow = MAX(0, lbuf_len(xb) - 1);
+        lbuf_undofree(xb);
         snprintf(xpath, PATHLEN, "%s", arg);
 }