]> git.lizzy.rs Git - micro.git/commitdiff
find: select prefilled text (#2127)
authorDmitry Maluka <dmitrymaluka@gmail.com>
Wed, 9 Jun 2021 21:04:11 +0000 (23:04 +0200)
committerGitHub <noreply@github.com>
Wed, 9 Jun 2021 21:04:11 +0000 (17:04 -0400)
The new feature of prefilling the search bar with the selected text (added
in 3d0b5db) has an annoying side effect: if we do have some text selected
but we want to search for some other pattern, not the selected text,
then we have to manually delete the prefilled text before we can start
entering our wanted search pattern.

A simple solution is to select the prefilled text, so that we can replace it
with our pattern right away just by typing, without any additional keystrokes.

internal/action/actions.go

index 892bc5555f33a3f68e38f86b9a73bef3a3a056c1..17875c691ff1ba2fd9d1e756948ebe8df557ea12 100644 (file)
@@ -932,6 +932,9 @@ func (h *BufPane) find(useRegex bool) bool {
                eventCallback(pattern)
        }
        InfoBar.Prompt(prompt, pattern, "Find", eventCallback, findCallback)
+       if pattern != "" {
+               InfoBar.SelectAll()
+       }
        return true
 }