1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-25 22:32:13 +02:00

Allow more than one controller to attach OnFocus/OnFocusLost functions

Trying to do this would previously have the second one silently overwrite the
first one's.

We don't currently have this in lazygit, but I ran into the situation once
during development, and it can lead to bugs that are hard to diagnose.

Instead of holding a list of functions, we could also have added a panic in case
the function was set already; this would have been good enough for the current
state, and enough to catch mistakes early in the future. However, I decided to
allow multiple controllers to attach these functions, because I can't see a
reason not to.
This commit is contained in:
Stefan Haller
2025-07-10 20:03:50 +02:00
parent 9c5c459faa
commit 4dfa4e8aa2
4 changed files with 13 additions and 11 deletions

View File

@@ -21,7 +21,7 @@ func (gui *Gui) Helpers() *helpers.Helpers {
// the lower in the list the keybindings will appear.
func (gui *Gui) resetHelpersAndControllers() {
for _, context := range gui.Contexts().Flatten() {
context.ClearAllBindingsFn()
context.ClearAllAttachedControllerFunctions()
}
helperCommon := gui.c