Don't call onSetActive for an already active pane

Currently onSetActive is called when the user clicks with the mouse on
a pane even if this pane is already active. We should avoid calling it
in this case.

Implementation detail: like with tabs in the previous commit, we cannot
check if the pane is already active just by checking the index passed
to the Tab's SetActive() (since the index may not change while the pane
itself changes), we need to check state of the pane itself. So we move
the onSetActive invocation from the Tab's SetActive() to the BufPane's
SetActive().
This commit is contained in:
Dmytro Maluka
2024-04-12 02:21:03 +02:00
parent c6dc5a4b1f
commit 2a1790d15a
2 changed files with 9 additions and 6 deletions

View File

@@ -679,6 +679,10 @@ func (h *BufPane) Close() {
// SetActive marks this pane as active.
func (h *BufPane) SetActive(b bool) {
if h.IsActive() == b {
return
}
h.BWindow.SetActive(b)
if b {
// Display any gutter messages for this line
@@ -694,8 +698,12 @@ func (h *BufPane) SetActive(b bool) {
if none && InfoBar.HasGutter {
InfoBar.ClearGutter()
}
}
err := config.RunPluginFn("onSetActive", luar.New(ulua.L, h))
if err != nil {
screen.TermMessage(err)
}
}
}
// BufKeyActions contains the list of all possible key actions the bufhandler could execute

View File

@@ -327,11 +327,6 @@ func (t *Tab) SetActive(i int) {
p.SetActive(false)
}
}
err := config.RunPluginFn("onSetActive", luar.New(ulua.L, MainTab().CurPane()))
if err != nil {
screen.TermMessage(err)
}
}
// GetPane returns the pane with the given split index