Skip to content

Commit 2a1790d

Browse files
committed
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().
1 parent c6dc5a4 commit 2a1790d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

internal/action/bufpane.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,10 @@ func (h *BufPane) Close() {
679679

680680
// SetActive marks this pane as active.
681681
func (h *BufPane) SetActive(b bool) {
682+
if h.IsActive() == b {
683+
return
684+
}
685+
682686
h.BWindow.SetActive(b)
683687
if b {
684688
// Display any gutter messages for this line
@@ -694,8 +698,12 @@ func (h *BufPane) SetActive(b bool) {
694698
if none && InfoBar.HasGutter {
695699
InfoBar.ClearGutter()
696700
}
697-
}
698701

702+
err := config.RunPluginFn("onSetActive", luar.New(ulua.L, h))
703+
if err != nil {
704+
screen.TermMessage(err)
705+
}
706+
}
699707
}
700708

701709
// BufKeyActions contains the list of all possible key actions the bufhandler could execute

internal/action/tab.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,6 @@ func (t *Tab) SetActive(i int) {
327327
p.SetActive(false)
328328
}
329329
}
330-
331-
err := config.RunPluginFn("onSetActive", luar.New(ulua.L, MainTab().CurPane()))
332-
if err != nil {
333-
screen.TermMessage(err)
334-
}
335330
}
336331

337332
// GetPane returns the pane with the given split index

0 commit comments

Comments
 (0)