fix: SFTP pane width — account for border in halfW calculation, fix innerW to maxW-2 (padding only), truncate filter line

Root cause: lipgloss Width(maxW) = content area inside border, border adds 2 chars extra.
- halfW was t.width/2, should be t.width/2-2 (reserve border per pane)
- innerW was maxW-4, should be maxW-2 (padding only, not border)
- Each pane total = maxW + 2 (content + border)
This commit is contained in:
swanadiva
2026-06-23 19:22:58 +07:00
parent 2cc9392e2b
commit ebd72cf16c
+18 -8
View File
@@ -541,14 +541,19 @@ func (t *SFTPBrowserTab) View() string {
}
// Responsive pane layout: stack vertically on narrow terminals
// Each pane renders at maxW+2 total (maxW content + 2 border chars)
var leftView, rightView string
if t.width < 50 {
// Stack vertically — each pane gets full width
leftView = t.renderPane(&t.left, paneLocal, t.width)
rightView = t.renderPane(&t.right, paneRemote, t.width)
// Stack vertically — each pane gets full width minus border
paneW := t.width - 2
if paneW < 20 {
paneW = 20
}
leftView = t.renderPane(&t.left, paneLocal, paneW)
rightView = t.renderPane(&t.right, paneRemote, paneW)
} else {
// Side by side — each pane gets half width
halfW := t.width / 2
// Side by side — reserve 2 chars border per pane
halfW := t.width/2 - 2
if halfW < 20 {
halfW = 20
}
@@ -601,8 +606,9 @@ func (t *SFTPBrowserTab) renderPane(p *sftpPane, pt paneType, maxW int) string {
paneStyle = StylePaneActive
}
// Inner content width: border(2) + padding(2) = 4 overhead
innerW := maxW - 4
// Inner content width: Width(maxW) sets content area inside border
// Padding(0,1) takes 2 chars → inner text = maxW - 2
innerW := maxW - 2
if innerW < 5 {
innerW = 5
}
@@ -689,7 +695,11 @@ func (t *SFTPBrowserTab) renderPane(p *sftpPane, pt paneType, maxW int) string {
}
if p.filterMode {
content.WriteString("\n" + SubtitleStyle.Render("Filter: "+p.filter+"_"))
filterLine := "Filter: " + p.filter + "_"
if lipgloss.Width(filterLine) > innerW {
filterLine = truncateStr(filterLine, innerW)
}
content.WriteString("\n" + SubtitleStyle.Render(filterLine))
}
inner := titleBar + "\n" + content.String()