From 1400f6fa9b7b97dbfb4cc97dd71bd052d9d79243 Mon Sep 17 00:00:00 2001 From: Hemming Svensson Date: Tue, 27 Jan 2026 23:56:37 +0100 Subject: [PATCH] feat(textfilter): Select output if input was from selection --- internal/action/command.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/action/command.go b/internal/action/command.go index 7bbfe131d..d676cfadf 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -141,9 +141,11 @@ func (h *BufPane) TextFilterCmd(args []string) { InfoBar.Error("usage: textfilter arguments") return } + for _, c := range h.Buf.GetCursors() { sel := c.GetSelection() - if len(sel) == 0 { + fromSelection := len(sel) > 0 + if !fromSelection { c.SelectWord() sel = c.GetSelection() } @@ -158,7 +160,18 @@ func (h *BufPane) TextFilterCmd(args []string) { return } c.DeleteSelection() - h.Buf.Insert(c.Loc, bout.String()) + insertStart := c.Loc + insertedText := bout.String() + h.Buf.Insert(c.Loc, insertedText) + + if fromSelection { + // Select the pasted output if the input was selected + charCount := util.CharacterCountInString(insertedText) + insertEnd := insertStart.Move(charCount, h.Buf) + c.SetSelectionStart(insertStart) + c.SetSelectionEnd(insertEnd) + c.Loc = insertEnd + } } }