mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-03 00:57:52 +02:00
Support authors and tags in custom command suggestions preset
This commit is contained in:
@ -101,7 +101,7 @@ These fields are applicable to all prompts.
|
|||||||
The permitted suggestions fields are:
|
The permitted suggestions fields are:
|
||||||
| _field_ | _description_ | _required_ |
|
| _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 |
|
| 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:
|
Here's an example of passing a preset:
|
||||||
|
@ -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 {
|
func (self *SuggestionsHelper) GetRefsSuggestionsFunc() func(string) []*types.Suggestion {
|
||||||
remoteBranchNames := self.getRemoteBranchNames("/")
|
remoteBranchNames := self.getRemoteBranchNames("/")
|
||||||
localBranchNames := self.getBranchNames()
|
localBranchNames := self.getBranchNames()
|
||||||
|
@ -161,16 +161,20 @@ func (self *HandlerCreator) getCommandSuggestionsFn(command string) (func(string
|
|||||||
|
|
||||||
func (self *HandlerCreator) getPresetSuggestionsFn(preset string) (func(string) []*types.Suggestion, error) {
|
func (self *HandlerCreator) getPresetSuggestionsFn(preset string) (func(string) []*types.Suggestion, error) {
|
||||||
switch preset {
|
switch preset {
|
||||||
case "files":
|
case "authors":
|
||||||
return self.suggestionsHelper.GetFilePathSuggestionsFunc(), nil
|
return self.suggestionsHelper.GetAuthorsSuggestionsFunc(), nil
|
||||||
case "branches":
|
case "branches":
|
||||||
return self.suggestionsHelper.GetBranchNameSuggestionsFunc(), nil
|
return self.suggestionsHelper.GetBranchNameSuggestionsFunc(), nil
|
||||||
|
case "files":
|
||||||
|
return self.suggestionsHelper.GetFilePathSuggestionsFunc(), nil
|
||||||
|
case "refs":
|
||||||
|
return self.suggestionsHelper.GetRefsSuggestionsFunc(), nil
|
||||||
case "remotes":
|
case "remotes":
|
||||||
return self.suggestionsHelper.GetRemoteSuggestionsFunc(), nil
|
return self.suggestionsHelper.GetRemoteSuggestionsFunc(), nil
|
||||||
case "remoteBranches":
|
case "remoteBranches":
|
||||||
return self.suggestionsHelper.GetRemoteBranchesSuggestionsFunc("/"), nil
|
return self.suggestionsHelper.GetRemoteBranchesSuggestionsFunc("/"), nil
|
||||||
case "refs":
|
case "tags":
|
||||||
return self.suggestionsHelper.GetRefsSuggestionsFunc(), nil
|
return self.suggestionsHelper.GetTagsSuggestionsFunc(), nil
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("Unknown value for suggestionsPreset in custom command: %s. Valid values: files, branches, remotes, remoteBranches, refs", preset)
|
return nil, fmt.Errorf("Unknown value for suggestionsPreset in custom command: %s. Valid values: files, branches, remotes, remoteBranches, refs", preset)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user