From 68ab0f49f2acddaa479dc8bf0b0af0e72859ae4d Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 26 Sep 2018 22:47:10 -0400 Subject: [PATCH] fixed logic for snapping selection to beginning and end of selected lines --- TODO.md | 6 +++--- tide.c | 15 +++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/TODO.md b/TODO.md index e0b1657..d3bdb41 100644 --- 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 b16dd31..d5ae95b 100644 --- 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); } -- 2.51.0