mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 06:12:35 +09:00
Merge pull request #3245 from dmaluka/onsetactive-fix
Fix issues with `onSetActive` callback
This commit is contained in:
@@ -689,6 +689,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
|
||||
@@ -704,8 +708,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
|
||||
|
||||
@@ -147,6 +147,25 @@ func (t *TabList) Display() {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TabList) SetActive(a int) {
|
||||
t.TabWindow.SetActive(a)
|
||||
|
||||
for i, p := range t.List {
|
||||
if i == a {
|
||||
if !p.isActive {
|
||||
p.isActive = true
|
||||
|
||||
err := config.RunPluginFn("onSetActive", luar.New(ulua.L, p.CurPane()))
|
||||
if err != nil {
|
||||
screen.TermMessage(err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.isActive = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tabs is the global tab list
|
||||
var Tabs *TabList
|
||||
|
||||
@@ -192,6 +211,9 @@ func MainTab() *Tab {
|
||||
type Tab struct {
|
||||
*views.Node
|
||||
*display.UIWindow
|
||||
|
||||
isActive bool
|
||||
|
||||
Panes []Pane
|
||||
active int
|
||||
|
||||
@@ -305,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
|
||||
|
||||
Reference in New Issue
Block a user