1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-23 22:24:51 +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

@@ -88,7 +88,7 @@ type IBaseContext interface {
AddKeybindingsFn(KeybindingsFn)
AddMouseKeybindingsFn(MouseKeybindingsFn)
ClearAllBindingsFn()
ClearAllAttachedControllerFunctions()
// This is a bit of a hack at the moment: we currently only set an onclick function so that
// our list controller can come along and wrap it in a list-specific click handler.