From 26fa15c1476444600f30b20afd1cb1ce274d534b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:44:24 +0200 Subject: [PATCH 1/3] action: Stop action iteration in the moment the current pane isn't a `BufPane` --- internal/action/bufpane.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/action/bufpane.go b/internal/action/bufpane.go index cd53e688..43cc8d8c 100644 --- a/internal/action/bufpane.go +++ b/internal/action/bufpane.go @@ -169,6 +169,10 @@ func BufMapEvent(k Event, action string) { // if the action changed the current pane, update the reference h = MainTab().CurPane() success = innerSuccess + if h == nil { + // stop, in case the current pane is not a BufPane + break + } } return true } From 3919cf399f5522ce0dd677a18ca8a660cc29ac10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:57:07 +0200 Subject: [PATCH 2/3] action: Provide `Name()` to treat `TermPane` as `Pane` This will add the capability to address the `TermPane` within the tabs, since the tab list only stores panes. --- internal/action/termpane.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/action/termpane.go b/internal/action/termpane.go index bbb1e17b..f440f0cd 100644 --- a/internal/action/termpane.go +++ b/internal/action/termpane.go @@ -81,6 +81,10 @@ func (t *TermPane) SetID(i uint64) { t.id = i } +func (t *TermPane) Name() string { + return t.Terminal.Name() +} + func (t *TermPane) SetTab(tab *Tab) { t.tab = tab } From 07cda68795f511bdb94a9b3a617513518637d1e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:50:10 +0200 Subject: [PATCH 3/3] initlua: Correct return type of `CurPane()` to be of type `*BufPane` --- cmd/micro/initlua.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/micro/initlua.go b/cmd/micro/initlua.go index 77349caa..7eac5637 100644 --- a/cmd/micro/initlua.go +++ b/cmd/micro/initlua.go @@ -48,7 +48,7 @@ func luaImportMicro() *lua.LTable { ulua.L.SetField(pkg, "InfoBar", luar.New(ulua.L, action.GetInfoBar)) ulua.L.SetField(pkg, "Log", luar.New(ulua.L, log.Println)) ulua.L.SetField(pkg, "SetStatusInfoFn", luar.New(ulua.L, display.SetStatusInfoFnLua)) - ulua.L.SetField(pkg, "CurPane", luar.New(ulua.L, func() action.Pane { + ulua.L.SetField(pkg, "CurPane", luar.New(ulua.L, func() *action.BufPane { return action.MainTab().CurPane() })) ulua.L.SetField(pkg, "CurTab", luar.New(ulua.L, action.MainTab))