mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-12 15:53:33 -04:00
Let the search prompt receive pasted text in one piece
Treat pasted text like in the other views that take a single line of text. Before, a pasted newline confirmed the search, and the rest of the pasted text was lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
417dea6381
commit
9765b96790
@@ -119,6 +119,13 @@ func (gui *Gui) onMenuFilterContentChanged(content string) {
|
||||
gui.helpers.Search.ApplyFilter(menuContext, content)
|
||||
}
|
||||
|
||||
func (gui *Gui) pasteIntoSearch(text string) {
|
||||
v := gui.Views.Search
|
||||
if typePastedTextIntoSingleLineView(v, text) {
|
||||
gui.helpers.Search.OnPromptContentChanged(v.TextArea.GetContent())
|
||||
}
|
||||
}
|
||||
|
||||
func (gui *Gui) searchEditor(v *gocui.View, key gocui.Key) bool {
|
||||
matched := gui.handleEditorKeypress(v, key, false)
|
||||
v.RenderTextArea()
|
||||
|
||||
@@ -101,6 +101,10 @@ func (gui *Gui) createAllViews() error {
|
||||
gui.Views.Search.Editable = true
|
||||
gui.Views.Search.Frame = false
|
||||
gui.Views.Search.Editor = gocui.EditorFunc(gui.searchEditor)
|
||||
gui.Views.Search.OnPaste = func(text string) error {
|
||||
gui.pasteIntoSearch(text)
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, view := range []*gocui.View{gui.Views.Main, gui.Views.Secondary, gui.Views.MergeConflicts} {
|
||||
view.Wrap = true
|
||||
|
||||
@@ -24,6 +24,13 @@ func (self *SearchDriver) Type(value string) *SearchDriver {
|
||||
return self
|
||||
}
|
||||
|
||||
// pastes the text the way a terminal does it
|
||||
func (self *SearchDriver) Paste(text string) *SearchDriver {
|
||||
self.t.paste(text)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *SearchDriver) Clear() *SearchDriver {
|
||||
self.t.press(ClearKey)
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package filter_and_search
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var PasteIntoSearchPrompt = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Paste multi-line text into the search prompt",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("one")
|
||||
shell.EmptyCommit("two")
|
||||
shell.EmptyCommit("three")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("three").IsSelected(),
|
||||
Contains("two"),
|
||||
Contains("one"),
|
||||
).
|
||||
Press(keys.Universal.StartSearch)
|
||||
|
||||
t.ExpectSearch().
|
||||
Paste("\ntwo\n")
|
||||
|
||||
t.Views().Search().
|
||||
IsFocused().
|
||||
Content(Equals("two"))
|
||||
|
||||
t.ExpectSearch().
|
||||
Confirm()
|
||||
|
||||
t.Views().Search().
|
||||
IsVisible().
|
||||
Content(Contains("matches for 'two' (1 of 1)"))
|
||||
|
||||
t.Views().Commits().
|
||||
Lines(
|
||||
Contains("three"),
|
||||
Contains("two").IsSelected(),
|
||||
Contains("one"),
|
||||
)
|
||||
},
|
||||
})
|
||||
@@ -339,6 +339,7 @@ var tests = []*components.IntegrationTest{
|
||||
filter_and_search.NewSearch,
|
||||
filter_and_search.PasteIntoKeybindingsMenu,
|
||||
filter_and_search.PasteIntoMenuFilter,
|
||||
filter_and_search.PasteIntoSearchPrompt,
|
||||
filter_and_search.RerenderTheSearchedMainView,
|
||||
filter_and_search.SearchALongDiff,
|
||||
filter_and_search.SearchStatusAfterARerender,
|
||||
|
||||
Reference in New Issue
Block a user