From eb125df27320fbf55ba2d0af12ce37164ac815ec Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 25 Sep 2018 22:48:45 -0400 Subject: [PATCH] attempt to fix selection logic after trimming whitespace. This implementation is wrong. --- lib/buf.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/buf.c b/lib/buf.c index 3827fb0..c116177 100644 --- 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; } -- 2.49.0