]> git.mdlowis.com Git - projs/tide.git/commitdiff
attempt to fix selection logic after trimming whitespace. This implementation is...
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 26 Sep 2018 02:48:45 +0000 (22:48 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 26 Sep 2018 02:48:45 +0000 (22:48 -0400)
lib/buf.c

index 3827fb0c098d1239eb10d5c11e7cc1a9654cdd32..c11617723448511ee80a7e5b40b5db1e45fb1818 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -157,12 +157,16 @@ static void trim_whitespace(Buf* buf) {
         }
 
         /* if current char is not whitespace, then shrink the selection */               
-        if (r != ' ' && r != '\t')
+        if (r != ' ' && r != '\t') {
             buf->selection.beg = buf->selection.end;
+        } else {
+            if (buf->selection.end <= sel.beg) sel.beg--;
+            if (buf->selection.end <= sel.end) sel.end--;
+        }
 
-       /* move to the next character */
-       prev = buf->selection.end;
-       buf->selection.end = buf_byrune(buf, buf->selection.end, +1);
+        /* move to the next character */
+        prev = buf->selection.end;
+        buf->selection.end = buf_byrune(buf, buf->selection.end, +1);
     }    
     buf->selection = sel;
 }