New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete and edit custom commands history items #3534
base: master
Are you sure you want to change the base?
Delete and edit custom commands history items #3534
Conversation
Marking this as a draft for now because I didn't add tests yet. Before I spend time on that I first wanted to confirm that we want this. (I find it pretty useful myself.) |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more |
Just for future reference, this will close #2528 . |
e4a68b8
to
6eef8f2
Compare
Handler: func() error { return self.c.ReplaceContext(self.c.Contexts().Confirmation) }, | ||
Key: opts.GetKey(opts.Config.Universal.TogglePanel), | ||
Handler: func() error { | ||
if self.context().State.FillInTextOnTogglePanel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this returns false, we should still replace the context, right?
EDIT: wait that's exactly what's happening: I misread the indentation
In the custom commands panel you can now tab to the suggestions and hit 'd' to delete items from there. Useful if you mistyped a command and don't want it to appear in your history any more.
For custom commands it is useful to select an earlier command and have it copied to the prompt for further editing. This can be done by hitting 'e' now. For other types of suggestion panels we don't enable this behavior, as you can't create arbitrary new items there that don't already exist as a suggestion.
6eef8f2
to
f4231fd
Compare
f4231fd
to
5d3f2a0
Compare
@jesseduffield I changed the keybinding for editing a history command from tab to "e", as discussed; and added a commit that shows the keybindings in the subtitle of the suggestions panel (only if it is focused). |
// are also editable, so we show both keybindings | ||
subtitle = fmt.Sprintf(self.c.Tr.SuggestionsSubtitle, | ||
self.c.UserConfig.Keybinding.Universal.Remove, self.c.UserConfig.Keybinding.Universal.Edit) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jesseduffield I'm showing the keybindings when the suggestions panel gets the focus (and remove it again in the opposite handler in SuggestionsController). I would have preferred not to do this here, but in GetOnFocus/GetOnFocusLost, so that it is reliably called no matter how we switch focus (maybe we want to make it possible some day to click on a suggestion to select it).
But that's not possible right now because ContextMgr.Replace
only calls Activate on the new context, but not deactivate on the old one. I tried to "fix" that, but that's not possible because the GetOnFocusLost of both ConfirmationController and SuggestionsController destroys the panel.
I'm not sure how to solve this cleanly; let me know if you have any suggestions. For now we just put it here in the tab handler, which works fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I am not sure how to solve that cleanly. Happy to use your stopgap solution
Allow deleting and editing custom command history items. Deleting is done by hitting
d
on a suggestion; editing is done by hittinge
, which fills the selected item into the command prompt for further editing.Closes #2528.
go generate ./...
)docs/Config.md
) have been updated if necessary