From 0bcb821c33ac1f1d71b0f3b74f6c414c97cbf794 Mon Sep 17 00:00:00 2001 From: Philip Henning Date: Wed, 13 Aug 2025 16:16:53 +0200 Subject: [PATCH] Fix pane border overflow --- internal/tui/update.go | 24 +++++++++++++++++++++--- internal/tui/view.go | 26 +++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/internal/tui/update.go b/internal/tui/update.go index 909e5b5..15b220b 100644 --- a/internal/tui/update.go +++ b/internal/tui/update.go @@ -42,9 +42,27 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.WindowSizeMsg: m.width = msg.Width m.height = msg.Height - 1 - m.list.SetSize(msg.Width/2, m.height) - m.detail.Width = msg.Width - msg.Width/2 - m.detail.Height = m.height + + leftWidth := msg.Width / 2 + rightWidth := msg.Width - leftWidth + leftHeight := m.height + rightHeight := m.height + + if m.focus == listPane { + leftWidth -= 2 + leftHeight -= 2 + } else { + rightWidth -= 2 + rightHeight -= 2 + } + + leftWidth -= 2 + rightWidth -= 2 + + m.list.SetSize(leftWidth, leftHeight) + m.detail.Width = rightWidth + m.detail.Height = rightHeight + if m.focus == listPane { m.list, cmd = m.list.Update(msg) } diff --git a/internal/tui/view.go b/internal/tui/view.go index b6a27cd..ecc371e 100644 --- a/internal/tui/view.go +++ b/internal/tui/view.go @@ -18,15 +18,35 @@ func (m Model) View() string { listView := m.list.View() detailView := m.detail.View() - left := listStyle.Width(m.width / 2).Height(m.height).Render(listView) - right := detailStyle.Width(m.width - m.width/2).Height(m.height).Render(detailView) + // compute dimensions for each pane accounting for padding and focus border + leftWidth := m.width / 2 + rightWidth := m.width - leftWidth + leftHeight := m.height + rightHeight := m.height + + if m.focus == listPane { + leftWidth -= 2 // border + leftHeight -= 2 + } else { + rightWidth -= 2 + rightHeight -= 2 + } + + // account for horizontal padding + leftWidth -= 2 + rightWidth -= 2 + + left := listStyle.Width(leftWidth).Height(leftHeight).Render(listView) + right := detailStyle.Width(rightWidth).Height(rightHeight).Render(detailView) + if m.focus == listPane { left = focusedStyle.Render(left) } else { right = focusedStyle.Render(right) } - panes := lipgloss.JoinHorizontal(lipgloss.Top, left, right) + // join panes and status bar + panes := lipgloss.JoinHorizontal(lipgloss.Top, left, right) status := fmt.Sprintf("VIEW MODE • %d entries", len(m.hosts.Entries)) bar := statusStyle.Width(m.width).Render(status) return lipgloss.JoinVertical(lipgloss.Left, panes, bar)