account: fix split views when sidebar is hidden

updateSplitView() used hardcoded grid positions that assumed the
sidebar was always visible, causing a crash when opening a split
view with the sidebar hidden.

closeSplit() also ignored the sidebar visibility state, causing
the sidebar to reappear when closing a split.

Fix both by checking hasSidebar() for correct column positions
and reusing buildGrid() in closeSplit().

Fixes: 66cf16c4 ("commands: add :toggle-sidebar command")
Signed-off-by: Matthew Phillips <matthew@matthewphillips.info>
Tested-by: Julio B <julio.bacel@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Matthew Phillips
2025-12-04 08:29:27 -05:00
committed by Robin Jarry
parent 752f7a0cad
commit 44048c1c8e

View File

@@ -684,17 +684,7 @@ func (acct *AccountView) closeSplit() {
acct.splitSize = 0
acct.splitDir = config.SPLIT_NONE
acct.split = nil
acct.grid = ui.NewGrid().Rows([]ui.GridSpec{
{Strategy: ui.SIZE_WEIGHT, Size: ui.Const(1)},
}).Columns([]ui.GridSpec{
{Strategy: ui.SIZE_EXACT, Size: func() int {
return acct.UiConfig().SidebarWidth
}},
{Strategy: ui.SIZE_WEIGHT, Size: ui.Const(1)},
})
acct.grid.AddChild(ui.NewBordered(acct.dirlist, ui.BORDER_RIGHT, acct.UiConfig()))
acct.grid.AddChild(acct.msglist).At(0, 1)
acct.buildGrid()
ui.Invalidate()
}
@@ -734,9 +724,17 @@ func (acct *AccountView) updateSplitView(msg *models.MessageInfo) {
acct.split = viewer
switch acct.splitDir {
case config.SPLIT_HORIZONTAL:
acct.grid.AddChild(acct.split).At(1, 1)
if acct.hasSidebar() {
acct.grid.AddChild(acct.split).At(1, 1)
} else {
acct.grid.AddChild(acct.split).At(1, 0)
}
case config.SPLIT_VERTICAL:
acct.grid.AddChild(acct.split).At(0, 2)
if acct.hasSidebar() {
acct.grid.AddChild(acct.split).At(0, 2)
} else {
acct.grid.AddChild(acct.split).At(0, 1)
}
}
// If the user wants to, start a timer to mark the message read
// if it stays in the message viewer longer than the requested