fix: empty-state
This commit is contained in:
parent
8cad917626
commit
401107df4d
|
|
@ -385,28 +385,23 @@ func (m *Model) updateSizes() {
|
||||||
reservedHeight += 6
|
reservedHeight += 6
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate main area height
|
|
||||||
contentHeight := m.height - reservedHeight
|
contentHeight := m.height - reservedHeight
|
||||||
if contentHeight < 1 {
|
if contentHeight < 1 {
|
||||||
contentHeight = 1
|
contentHeight = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate widths
|
|
||||||
treeWidth := int(float64(m.width) * 0.20)
|
treeWidth := int(float64(m.width) * 0.20)
|
||||||
if treeWidth < 20 {
|
if treeWidth < 20 {
|
||||||
treeWidth = 20
|
treeWidth = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
// The Tree PaneStyle has a border (1 top, 1 bottom = 2 lines).
|
// Subtract border height (2) from contentHeight
|
||||||
// We must subtract this from the content height for the inner list.
|
|
||||||
listHeight := contentHeight - 2
|
listHeight := contentHeight - 2
|
||||||
if listHeight < 1 {
|
if listHeight < 1 {
|
||||||
listHeight = 1
|
listHeight = 1
|
||||||
}
|
}
|
||||||
m.fileList.SetSize(treeWidth, listHeight)
|
m.fileList.SetSize(treeWidth, listHeight)
|
||||||
|
|
||||||
// We align the Diff Viewport height with the List height to ensure
|
|
||||||
// the bottom edges match visually and to prevent overflow.
|
|
||||||
m.diffViewport.Width = m.width - treeWidth - 2
|
m.diffViewport.Width = m.width - treeWidth - 2
|
||||||
m.diffViewport.Height = listHeight
|
m.diffViewport.Height = listHeight
|
||||||
}
|
}
|
||||||
|
|
@ -498,8 +493,6 @@ func (m Model) View() string {
|
||||||
renderedDiff.WriteString(lineNumRendered + line + "\n")
|
renderedDiff.WriteString(lineNumRendered + line + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trim the trailing newline to prevent an extra empty line
|
|
||||||
// which pushes the layout height +1 and causes the top bar to scroll off.
|
|
||||||
diffContentStr := strings.TrimRight(renderedDiff.String(), "\n")
|
diffContentStr := strings.TrimRight(renderedDiff.String(), "\n")
|
||||||
|
|
||||||
rightPaneView = DiffStyle.Copy().
|
rightPaneView = DiffStyle.Copy().
|
||||||
|
|
@ -661,16 +654,9 @@ func (m Model) renderEmptyState(w, h int, statusMsg string) string {
|
||||||
guides,
|
guides,
|
||||||
)
|
)
|
||||||
|
|
||||||
var verticalPad string
|
// Use lipgloss.Place to center the content in the available space
|
||||||
if h > lipgloss.Height(content) {
|
// This automatically handles vertical and horizontal centering.
|
||||||
lines := (h - lipgloss.Height(content)) / 2
|
return lipgloss.Place(w, h, lipgloss.Center, lipgloss.Center, content)
|
||||||
verticalPad = strings.Repeat("\n", lines)
|
|
||||||
}
|
|
||||||
|
|
||||||
return lipgloss.JoinVertical(lipgloss.Top,
|
|
||||||
verticalPad,
|
|
||||||
lipgloss.PlaceHorizontal(w, lipgloss.Center, content),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func stripAnsi(str string) string {
|
func stripAnsi(str string) string {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user