]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed selection handling for view_fetch
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 12 May 2018 02:11:08 +0000 (22:11 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 12 May 2018 02:11:08 +0000 (22:11 -0400)
lib/buf.c

index 57ae90020188b4bfc2e874be0341ca38d79bb71b..47350d3aa70a56893bf609397370633ca93b3328 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -429,11 +429,17 @@ bool buf_insel(Buf* buf, size_t off) {
 }
 
 char* buf_fetch(Buf* buf, bool (*isword)(Rune), size_t off) {
+    char* str = NULL;
+    Sel prev = buf->selection;
     if (!buf_insel(buf, off)) {
         buf->selection = (Sel){ .beg = off, .end = off };
         buf_selword(buf, isword);
+        str = buf_gets(buf);
+    } else {
+        str = strdup("");
     }
-    return buf_gets(buf);
+    buf->selection = prev;
+    return str;
 }
 
 /******************************************************************************/