diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-11-28 20:01:45 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-11-28 20:48:17 +1100 |
commit | f31fbc10f6a60e493dd09ff602b08b83bd2124fe (patch) | |
tree | cee96887782a543d05a409da5db64fea51afc9f8 /pkg/gui/editors.go | |
parent | be404068ffeda8eb43246db77f67573aae3079f3 (diff) |
soft code finding of suggestions
Diffstat (limited to 'pkg/gui/editors.go')
-rw-r--r-- | pkg/gui/editors.go | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/pkg/gui/editors.go b/pkg/gui/editors.go index 2e4cdd78c..0faa2b6fa 100644 --- a/pkg/gui/editors.go +++ b/pkg/gui/editors.go @@ -2,9 +2,6 @@ package gui import ( "github.com/jesseduffield/gocui" - "github.com/jesseduffield/lazygit/pkg/gui/presentation" - "github.com/jesseduffield/lazygit/pkg/gui/types" - "github.com/jesseduffield/lazygit/pkg/utils" ) // we've just copy+pasted the editor from gocui to here so that we can also re- @@ -77,28 +74,9 @@ func (gui *Gui) editorWithCallback(v *gocui.View, key gocui.Key, ch rune, mod go v.EditWrite(ch) } - input := v.Buffer() - branchNames := gui.getBranchNames() - - matchingBranchNames := utils.FuzzySearch(input, branchNames) - - suggestions := make([]*types.Suggestion, len(matchingBranchNames)) - for i, branchName := range matchingBranchNames { - suggestions[i] = &types.Suggestion{ - Value: branchName, - Label: utils.ColoredString(branchName, presentation.GetBranchColor(branchName)), - } - } - - gui.setSuggestions(suggestions) -} - -func (gui *Gui) getBranchNames() []string { - result := make([]string, len(gui.State.Branches)) - - for i, branch := range gui.State.Branches { - result[i] = branch.Name + if gui.findSuggestions != nil { + input := v.Buffer() + suggestions := gui.findSuggestions(input) + gui.setSuggestions(suggestions) } - - return result } |