Fix directory preview layout to exactly match browser pane columns
Root cause: renderPreviewPane() was stuffing directory entries into the viewport model via SetContent(), then rendering through renderPreviewContent() which wraps the viewport in an additional border+padding box. This reduced the effective content width by 4 characters compared to the browser pane's innerWidth (width-2), causing column misalignment where the date column would wrap to the next line. Fix: For directory previews, directly render entries using the same renderPaneRows() and renderColumnsHeader() functions as the browser pane, at the same innerWidth. A temporary BrowserPane is created with the directory entries, and renderPaneRows() is called with active=false, producing pixel-identical output to the main file browser. Removed renderDirectoryPreviewBody() which is no longer needed.
This commit is contained in:
parent
db5eaba409
commit
bba8783f10
3 changed files with 22 additions and 7 deletions
|
|
@ -2363,7 +2363,18 @@ func renderPreviewPane(preview vfs.Preview, viewportModel *viewport.Model, cfg c
|
|||
contentHeight := max(innerHeight-usedHeight, 3)
|
||||
viewportModel.Width = max(innerWidth-2, 10)
|
||||
viewportModel.Height = max(contentHeight-3, 1)
|
||||
parts = append(parts, renderPreviewContent(viewportModel, palette, innerWidth, contentHeight))
|
||||
|
||||
// Directory previews: borrow the column layout from the browser pane
|
||||
// (renderPaneRows + renderColumnsHeader at the same innerWidth),
|
||||
// but non-interactive (no cursor, no selection).
|
||||
if preview.Kind == vfs.PreviewKindDirectory && len(preview.Entries) > 0 {
|
||||
dirPane := BrowserPane{Entries: preview.Entries}
|
||||
headerRow := renderColumnsHeader(cfg, innerWidth, palette, palette.Panel, useNerdfont)
|
||||
rows := renderPaneRows(dirPane, cfg, palette, innerWidth, contentHeight, false, -1, palette.Panel, useNerdfont)
|
||||
parts = append(parts, lipgloss.JoinVertical(lipgloss.Left, headerRow, rows))
|
||||
} else {
|
||||
parts = append(parts, renderPreviewContent(viewportModel, palette, innerWidth, contentHeight))
|
||||
}
|
||||
|
||||
content := lipgloss.NewStyle().
|
||||
Width(innerWidth).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue