Change MainTab calls (#3750)
Some checks failed
Build and Test / test (1.19.x, macos-latest) (push) Has been cancelled
Build and Test / test (1.19.x, ubuntu-latest) (push) Has been cancelled
Build and Test / test (1.19.x, windows-latest) (push) Has been cancelled
Build and Test / test (1.23.x, macos-latest) (push) Has been cancelled
Build and Test / test (1.23.x, ubuntu-latest) (push) Has been cancelled
Build and Test / test (1.23.x, windows-latest) (push) Has been cancelled

Swaping `MainTab` calls to `h.tab` will not change the normal micro
behaviour.
This changes will make possible to call `ForceQuit`, `VSplitIndex` and
`HSplitIndex` for tabs that aren't main one.
This commit is contained in:
cutelisp 2025-05-26 21:07:14 +01:00 committed by GitHub
parent cd0dc9a701
commit 5eddf5b85d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 12 deletions

View File

@ -1891,11 +1891,11 @@ func (h *BufPane) ClearInfo() bool {
return true return true
} }
// ForceQuit closes the current tab or view even if there are unsaved changes // ForceQuit closes the tab or view even if there are unsaved changes
// (no prompt) // (no prompt)
func (h *BufPane) ForceQuit() bool { func (h *BufPane) ForceQuit() bool {
h.Buf.Close() h.Buf.Close()
if len(MainTab().Panes) > 1 { if len(h.tab.Panes) > 1 {
h.Unsplit() h.Unsplit()
} else if len(Tabs.List) > 1 { } else if len(Tabs.List) > 1 {
Tabs.RemoveTab(h.splitID) Tabs.RemoveTab(h.splitID)

View File

@ -652,28 +652,28 @@ func (h *BufPane) DoRuneInsert(r rune) {
// VSplitIndex opens the given buffer in a vertical split on the given side. // VSplitIndex opens the given buffer in a vertical split on the given side.
func (h *BufPane) VSplitIndex(buf *buffer.Buffer, right bool) *BufPane { func (h *BufPane) VSplitIndex(buf *buffer.Buffer, right bool) *BufPane {
e := NewBufPaneFromBuf(buf, h.tab) e := NewBufPaneFromBuf(buf, h.tab)
e.splitID = MainTab().GetNode(h.splitID).VSplit(right) e.splitID = h.tab.GetNode(h.splitID).VSplit(right)
currentPaneIdx := MainTab().GetPane(h.splitID) currentPaneIdx := h.tab.GetPane(h.splitID)
if right { if right {
currentPaneIdx++ currentPaneIdx++
} }
MainTab().AddPane(e, currentPaneIdx) h.tab.AddPane(e, currentPaneIdx)
MainTab().Resize() h.tab.Resize()
MainTab().SetActive(currentPaneIdx) h.tab.SetActive(currentPaneIdx)
return e return e
} }
// HSplitIndex opens the given buffer in a horizontal split on the given side. // HSplitIndex opens the given buffer in a horizontal split on the given side.
func (h *BufPane) HSplitIndex(buf *buffer.Buffer, bottom bool) *BufPane { func (h *BufPane) HSplitIndex(buf *buffer.Buffer, bottom bool) *BufPane {
e := NewBufPaneFromBuf(buf, h.tab) e := NewBufPaneFromBuf(buf, h.tab)
e.splitID = MainTab().GetNode(h.splitID).HSplit(bottom) e.splitID = h.tab.GetNode(h.splitID).HSplit(bottom)
currentPaneIdx := MainTab().GetPane(h.splitID) currentPaneIdx := h.tab.GetPane(h.splitID)
if bottom { if bottom {
currentPaneIdx++ currentPaneIdx++
} }
MainTab().AddPane(e, currentPaneIdx) h.tab.AddPane(e, currentPaneIdx)
MainTab().Resize() h.tab.Resize()
MainTab().SetActive(currentPaneIdx) h.tab.SetActive(currentPaneIdx)
return e return e
} }