From 13fdd571980b917b4802c50cbf3328744564ed65 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 11 May 2018 22:11:08 -0400 Subject: [PATCH] fixed selection handling for view_fetch --- lib/buf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; } /******************************************************************************/ -- 2.49.0