fix: fs tree min width to be enough to not have line splits

This commit is contained in:
2026-01-27 03:18:39 +00:00
parent e7f450867b
commit e555d74b51
3 changed files with 52 additions and 20 deletions
+14 -2
View File
@@ -79,7 +79,11 @@ func (m *model) loadTreeCmd(path string) tea.Cmd {
func (m *model) layout(width, height int) {
m.terminalWidth = width
m.terminalHeight = height
m.fsTreeWidth, m.noteViewWidth = calculateLayout(width, m.fsTreeWidth)
minW := 0
if m.tree != nil {
minW = m.tree.ContentWidth()
}
m.fsTreeWidth, m.noteViewWidth = getUpdatedWindowSizes(width, m.fsTreeWidth, minW)
h := height
if m.showStatusBar || m.inputMode {
@@ -120,6 +124,8 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case treeLoadedMsg:
m.tree = msg.tree
m.loading = false
m.fsTreeWidth = m.tree.ContentWidth()
m.fsTreeWidth, m.noteViewWidth = getUpdatedWindowSizes(m.terminalWidth, m.fsTreeWidth, m.tree.ContentWidth())
_, cmd := m.tree.Update(tea.WindowSizeMsg{
Height: m.contentHeight,
Width: m.fsTreeWidth,
@@ -149,6 +155,12 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, cmd
}
case fstree.ContentSizeChangeMsg:
// layout update needed, sent when a new note is created
m.fsTreeWidth, m.noteViewWidth = getUpdatedWindowSizes(m.terminalWidth, m.tree.ContentWidth(), m.tree.ContentWidth())
// TODO: this can be simplified a lot
return m, m.resizeChildren() // batches two updates
case fstree.RequestInputMsg:
m.inputMode = true
m.pendingAction = msg.Action
@@ -250,7 +262,7 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.isHoveringDivider = isHoveringDivider(msg.X, m.fsTreeWidth)
if m.isDragging {
m.fsTreeWidth, m.noteViewWidth = calculateLayout(m.terminalWidth, msg.X)
m.fsTreeWidth, m.noteViewWidth = getUpdatedWindowSizes(m.terminalWidth, msg.X, m.tree.ContentWidth())
// Update children with new sizes
return m, m.resizeChildren()