summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-06-07 17:21:03 +1000
committerGitHub <noreply@github.com>2023-06-07 17:21:03 +1000
commitb6a31369da3f42c1254f6d5ba0ca4e4cb79f42f7 (patch)
treeb0fe726aad393e9e8f180efcd94d1e8a982ee0ad
parentced773ab18a116f926b2c28507d71cf283701fff (diff)
parenta694c458dd38d960189d4fc4b288e95ab692f404 (diff)
Merge pull request #2714 from jesseduffield/author-suggestions-custom-commands
-rw-r--r--docs/Custom_Command_Keybindings.md2
-rw-r--r--pkg/gui/controllers/helpers/suggestions_helper.go6
-rw-r--r--pkg/gui/services/custom_commands/handler_creator.go12
3 files changed, 15 insertions, 5 deletions
diff --git a/docs/Custom_Command_Keybindings.md b/docs/Custom_Command_Keybindings.md
index 7565b9f3a..7cc3d035b 100644
--- a/docs/Custom_Command_Keybindings.md
+++ b/docs/Custom_Command_Keybindings.md
@@ -101,7 +101,7 @@ These fields are applicable to all prompts.
The permitted suggestions fields are:
| _field_ | _description_ | _required_ |
|-----------------|----------------------|-|
-| preset | Uses built-in logic to obtain the suggestions. One of 'files', 'branches', 'remotes', 'remoteBranches', 'refs' | no |
+| preset | Uses built-in logic to obtain the suggestions. One of 'authors', 'branches', 'files', 'refs', 'remotes', 'remoteBranches', 'tags' | no |
| command | Command to run such that each line in the output becomes a suggestion. Mutually exclusive with 'preset' field. | no |
Here's an example of passing a preset:
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)
}