diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-23 10:46:02 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-23 12:29:52 +1100 |
commit | 629494144fcef931a9f484821202bcd4370aa23b (patch) | |
tree | ec7adf3bb2fc6c550f0ec52fdd61efd978a391d2 /pkg/gui/filtering.go | |
parent | b6a5e9d615f0fee7d76f5db33ff48bf32f0ef98b (diff) |
show suggestions when typing in an origin
Diffstat (limited to 'pkg/gui/filtering.go')
-rw-r--r-- | pkg/gui/filtering.go | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/pkg/gui/filtering.go b/pkg/gui/filtering.go index 17fd44e23..1f5c5032a 100644 --- a/pkg/gui/filtering.go +++ b/pkg/gui/filtering.go @@ -1,14 +1,5 @@ package gui -import ( - "os" - - "github.com/jesseduffield/lazygit/pkg/gui/types" - "github.com/jesseduffield/lazygit/pkg/utils" - "github.com/jesseduffield/minimal/gitignore" - "gopkg.in/ozeidan/fuzzy-patricia.v3/patricia" -) - func (gui *Gui) validateNotInFilterMode() (bool, error) { if gui.State.Modes.Filtering.Active() { err := gui.ask(askOpts{ @@ -49,60 +40,3 @@ func (gui *Gui) setFiltering(path string) error { gui.State.Contexts.BranchCommits.GetPanelState().SetSelectedLineIdx(0) }}) } - -// here we asynchronously fetch the latest set of paths in the repo and store in -// gui.State.FilesTrie. On the main thread we'll be doing a fuzzy search via -// gui.State.FilesTrie. So if we've looked for a file previously, we'll start with -// the old trie and eventually it'll be swapped out for the new one. -func (gui *Gui) getFindSuggestionsForFilterPath() func(string) []*types.Suggestion { - _ = gui.WithWaitingStatus(gui.Tr.LcLoadingFileSuggestions, func() error { - trie := patricia.NewTrie() - // load every non-gitignored file in the repo - ignore, err := gitignore.FromGit() - if err != nil { - return err - } - - err = ignore.Walk(".", - func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - trie.Insert(patricia.Prefix(path), path) - return nil - }) - // cache the trie for future use - gui.State.FilesTrie = trie - - // refresh the selections view - gui.suggestionsAsyncHandler.Do(func() func() { - // assuming here that the confirmation view is what we're typing into. - // This assumption may prove false over time - suggestions := gui.findSuggestions(gui.Views.Confirmation.TextArea.GetContent()) - return func() { gui.setSuggestions(suggestions) } - }) - - return err - }) - - return func(input string) []*types.Suggestion { - matchingNames := []string{} - _ = gui.State.FilesTrie.VisitFuzzy(patricia.Prefix(input), true, func(prefix patricia.Prefix, item patricia.Item, skipped int) error { - matchingNames = append(matchingNames, item.(string)) - return nil - }) - - // doing another fuzzy search for good measure - matchingNames = utils.FuzzySearch(input, matchingNames) - - suggestions := make([]*types.Suggestion, len(matchingNames)) - for i, name := range matchingNames { - suggestions[i] = &types.Suggestion{ - Value: name, - Label: name, - } - } - - return suggestions - } -} |