]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed logic for snapping selection to beginning and end of selected lines
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 27 Sep 2018 02:47:10 +0000 (22:47 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 27 Sep 2018 02:47:10 +0000 (22:47 -0400)
TODO.md
tide.c

diff --git a/TODO.md b/TODO.md
index e0b1657633ffccb979afa82fe31426f27e2c7a34..d3bdb41c4d22fc5925ed1a2c8f53f05f987e07b6 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -1,13 +1,14 @@
 # Issue List
 
-BUGS:
+## STAGING
 
 * no magic right click
 * implement mouse warping on search, jump to line, and focus change
 * gap buffer does not handle UTF-8 currently
 * mouse selection handling when mouse moves outside region
+* Line - Get the current line number(s) containing the selection
 
-Up Next:
+## BACKLOG
 
 * move mouse handlers back into tide.c
 * Add matching logic for "", '', ``, and <>
@@ -16,7 +17,6 @@ Up Next:
 Tags:
 
 * Clear - Clear the current window's edit buffer
-* Line - Get the current line number(s) containing the selection
 * Kill - Kill a background command
 * ID - Get window id of the X window
 * Zerox - Create a copy of the window
diff --git a/tide.c b/tide.c
index b16dd3105b40a2dd5a3a68298b773190391e9598..d5ae95b284278bcd284312205f777d090161e4a9 100644 (file)
--- a/tide.c
+++ b/tide.c
@@ -103,11 +103,15 @@ static void select_line(char* arg) {
     Buf* buf = win_buf(FOCUSED);
     if (buf->selection.beg <= buf->selection.end) {
         buf->selection.beg = buf_bol(buf, buf->selection.beg);
-        buf->selection.end = buf_eol(buf, buf->selection.end);
-        buf->selection.end = buf_byrune(buf, buf->selection.end, RIGHT);
+        if (!buf_iseol(buf, buf->selection.end)) {
+            buf->selection.end = buf_eol(buf, buf->selection.end);
+            buf->selection.end = buf_byrune(buf, buf->selection.end, RIGHT);
+        }
     } else {
-        buf->selection.beg = buf_eol(buf, buf->selection.beg);
-        buf->selection.beg = buf_byrune(buf, buf->selection.beg, RIGHT);
+        if (!buf_iseol(buf, buf->selection.beg)) {
+            buf->selection.beg = buf_eol(buf, buf->selection.beg);
+            buf->selection.beg = buf_byrune(buf, buf->selection.beg, RIGHT);
+        }
         buf->selection.end = buf_bol(buf, buf->selection.end);
     }
 }
@@ -391,8 +395,7 @@ static void highlight(char* arg) {
 }
 
 static void lnexec(char* cmd) {
-    if (!view_selsize(win_view(FOCUSED)))
-        select_line(NULL);
+    select_line(NULL);
     exec(cmd);
 }