diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-06-07 10:15:49 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-06-07 10:18:01 +1000 |
commit | a694c458dd38d960189d4fc4b288e95ab692f404 (patch) | |
tree | b0fe726aad393e9e8f180efcd94d1e8a982ee0ad /pkg | |
parent | ced773ab18a116f926b2c28507d71cf283701fff (diff) |
Support authors and tags in custom command suggestions preset
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/controllers/helpers/suggestions_helper.go | 6 | ||||
-rw-r--r-- | pkg/gui/services/custom_commands/handler_creator.go | 12 |
2 files changed, 14 insertions, 4 deletions
diff --git a/pkg/gui/controllers/helpers/suggestions_helper.go b/pkg/gui/controllers/helpers/suggestions_helper.go index 786ad7bfe..70fcf168a 100644 --- a/pkg/gui/controllers/helpers/suggestions_helper.go +++ b/pkg/gui/controllers/helpers/suggestions_helper.go @@ -157,6 +157,12 @@ func (self *SuggestionsHelper) getTagNames() []string { }) } +func (self *SuggestionsHelper) GetTagsSuggestionsFunc() func(string) []*types.Suggestion { + tagNames := self.getTagNames() + + return FuzzySearchFunc(tagNames) +} + func (self *SuggestionsHelper) GetRefsSuggestionsFunc() func(string) []*types.Suggestion { remoteBranchNames := self.getRemoteBranchNames("/") localBranchNames := self.getBranchNames() diff --git a/pkg/gui/services/custom_commands/handler_creator.go b/pkg/gui/services/custom_commands/handler_creator.go index 4dc6bc86e..404753edc 100644 --- a/pkg/gui/services/custom_commands/handler_creator.go +++ b/pkg/gui/services/custom_commands/handler_creator.go @@ -161,16 +161,20 @@ func (self *HandlerCreator) getCommandSuggestionsFn(command string) (func(string func (self *HandlerCreator) getPresetSuggestionsFn(preset string) (func(string) []*types.Suggestion, error) { switch preset { - case "files": - return self.suggestionsHelper.GetFilePathSuggestionsFunc(), nil + case "authors": + return self.suggestionsHelper.GetAuthorsSuggestionsFunc(), nil case "branches": return self.suggestionsHelper.GetBranchNameSuggestionsFunc(), nil + case "files": + return self.suggestionsHelper.GetFilePathSuggestionsFunc(), nil + case "refs": + return self.suggestionsHelper.GetRefsSuggestionsFunc(), nil case "remotes": return self.suggestionsHelper.GetRemoteSuggestionsFunc(), nil case "remoteBranches": return self.suggestionsHelper.GetRemoteBranchesSuggestionsFunc("/"), nil - case "refs": - return self.suggestionsHelper.GetRefsSuggestionsFunc(), nil + case "tags": + return self.suggestionsHelper.GetTagsSuggestionsFunc(), nil default: return nil, fmt.Errorf("Unknown value for suggestionsPreset in custom command: %s. Valid values: files, branches, remotes, remoteBranches, refs", preset) } |