From: Michael D. Lowis Date: Wed, 26 Sep 2018 02:48:45 +0000 (-0400) Subject: attempt to fix selection logic after trimming whitespace. This implementation is... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=eb125df27320fbf55ba2d0af12ce37164ac815ec;p=projs%2Ftide.git attempt to fix selection logic after trimming whitespace. This implementation is wrong. --- 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; }