From 3a7403bde4d508afea93a94d1113ca73cf37c1c1 Mon Sep 17 00:00:00 2001 From: hemmingsv <33031670+hemmingsv@users.noreply.github.com> Date: Wed, 28 Jan 2026 19:41:51 +0100 Subject: [PATCH] feat(textfilter): Select output if input was from selection (#3974) --- 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 7bbfe131..d676cfad 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 + } } }