From: Michael D. Lowis Date: Sat, 12 May 2018 02:11:08 +0000 (-0400) Subject: fixed selection handling for view_fetch X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=13fdd571980b917b4802c50cbf3328744564ed65;p=projs%2Ftide.git fixed selection handling for view_fetch --- diff --git a/lib/buf.c b/lib/buf.c index 57ae900..47350d3 100644 --- a/lib/buf.c +++ b/lib/buf.c @@ -429,11 +429,17 @@ bool buf_insel(Buf* buf, size_t off) { } char* buf_fetch(Buf* buf, bool (*isword)(Rune), size_t off) { + char* str = NULL; + Sel prev = buf->selection; if (!buf_insel(buf, off)) { buf->selection = (Sel){ .beg = off, .end = off }; buf_selword(buf, isword); + str = buf_gets(buf); + } else { + str = strdup(""); } - return buf_gets(buf); + buf->selection = prev; + return str; } /******************************************************************************/