fix: SFTP default to Local pane + fixed border height

- Default active pane changed from Remote to Local on SFTP init
- renderPane now takes maxH parameter for fixed border height
- paneStyle.Height(maxH) prevents border from shrinking/growing on scroll
- Stacked mode: maxH = t.height - 6; Side-by-side: t.height - 5
This commit is contained in:
swanadiva
2026-06-24 11:30:54 +07:00
parent 2e10308c75
commit 25a53d990b
3 changed files with 29 additions and 11 deletions
+21 -10
View File
@@ -79,7 +79,7 @@ func NewSFTPBrowserTab(host *models.Host, dataDir string) *SFTPBrowserTab {
return &SFTPBrowserTab{
host: host,
dataDir: dataDir,
active: paneRemote,
active: paneLocal,
left: sftpPane{
cwd: home,
localRoot: home,
@@ -565,10 +565,16 @@ func (t *SFTPBrowserTab) View() string {
}
indicator = lipgloss.JoinHorizontal(lipgloss.Top, indicatorParts[0], SubtitleStyle.Render(" "), indicatorParts[1])
// Height: t.height - 1(title) - 1(indicator) - 2(border) - 2(footer) = t.height - 6
paneH := t.height - 6
if paneH < 5 {
paneH = 5
}
if t.active == paneLocal {
leftView = t.renderPane(&t.left, paneLocal, paneW)
leftView = t.renderPane(&t.left, paneLocal, paneW, paneH)
} else {
leftView = t.renderPane(&t.right, paneRemote, paneW)
leftView = t.renderPane(&t.right, paneRemote, paneW, paneH)
}
} else {
// Side by side — reserve 2 chars border per pane
@@ -576,8 +582,13 @@ func (t *SFTPBrowserTab) View() string {
if halfW < 20 {
halfW = 20
}
leftView = t.renderPane(&t.left, paneLocal, halfW)
rightView = t.renderPane(&t.right, paneRemote, halfW)
// Height: t.height - 1(title) - 2(border) - 2(footer) = t.height - 5
paneH := t.height - 5
if paneH < 5 {
paneH = 5
}
leftView = t.renderPane(&t.left, paneLocal, halfW, paneH)
rightView = t.renderPane(&t.right, paneRemote, halfW, paneH)
}
var b strings.Builder
@@ -614,7 +625,7 @@ func (t *SFTPBrowserTab) View() string {
return b.String()
}
func (t *SFTPBrowserTab) renderPane(p *sftpPane, pt paneType, maxW int) string {
func (t *SFTPBrowserTab) renderPane(p *sftpPane, pt paneType, maxW, maxH int) string {
isActive := t.active == pt
title := "Local"
@@ -668,9 +679,9 @@ func (t *SFTPBrowserTab) renderPane(p *sftpPane, pt paneType, maxW int) string {
if len(visible) == 0 {
content.WriteString(SubtitleStyle.Render(" (empty)"))
} else {
maxDisplay := t.height - 6
if maxDisplay < 5 {
maxDisplay = 5
maxDisplay := maxH - 4
if maxDisplay < 1 {
maxDisplay = 1
}
start := 0
if p.selIdx >= maxDisplay {
@@ -724,7 +735,7 @@ func (t *SFTPBrowserTab) renderPane(p *sftpPane, pt paneType, maxW int) string {
}
inner := titleBar + "\n" + content.String()
return paneStyle.Width(maxW).Render(inner)
return paneStyle.Width(maxW).Height(maxH).Render(inner)
}
func (t *SFTPBrowserTab) Close() {