From 3d0b5db2e448aaf1c2181398fc41584ba47434a2 Mon Sep 17 00:00:00 2001 From: Ali Kefia Date: Wed, 2 Jun 2021 22:04:31 +0200 Subject: [PATCH] find: prefill with selection (#2115) * find: prefill with selection * keep search func - could be used in plugins --- internal/action/actions.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/action/actions.go b/internal/action/actions.go index beb63b07..892bc555 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -903,7 +903,7 @@ func (h *BufPane) find(useRegex bool) bool { h.Relocate() } } - InfoBar.Prompt(prompt, "", "Find", eventCallback, func(resp string, canceled bool) { + findCallback := func(resp string, canceled bool) { // Finished callback if !canceled { match, found, err := h.Buf.FindNext(resp, h.Buf.Start(), h.Buf.End(), h.searchOrig, true, useRegex) @@ -926,8 +926,12 @@ func (h *BufPane) find(useRegex bool) bool { h.Cursor.ResetSelection() } h.Relocate() - }) - + } + pattern := string(h.Cursor.GetSelection()) + if eventCallback != nil && pattern != "" { + eventCallback(pattern) + } + InfoBar.Prompt(prompt, pattern, "Find", eventCallback, findCallback) return true }