fix(tui): compute table Width from column sum, not terminal width
Table Width was set to terminal width, forcing lipgloss to redistribute surplus space into columns like #. Now computed from sum of column widths + border overhead. Table is exactly as wide as needed, capped at terminal.
This commit is contained in:
@@ -34,7 +34,16 @@ func (m Model) renderTable(headers []string, items int, buildRows func(start, en
|
|||||||
selectedVisual := m.cursor - m.tableOffset
|
selectedVisual := m.cursor - m.tableOffset
|
||||||
rows := buildRows(m.tableOffset, end)
|
rows := buildRows(m.tableOffset, end)
|
||||||
|
|
||||||
tableWidth := m.termWidth - chromePadH - 2
|
colTotal := 0
|
||||||
|
for _, w := range colWidths {
|
||||||
|
colTotal += w
|
||||||
|
}
|
||||||
|
borderOverhead := 2 + len(colWidths) - 1
|
||||||
|
tableWidth := colTotal + borderOverhead
|
||||||
|
maxWidth := m.termWidth - chromePadH - 2
|
||||||
|
if tableWidth > maxWidth {
|
||||||
|
tableWidth = maxWidth
|
||||||
|
}
|
||||||
if tableWidth < 40 {
|
if tableWidth < 40 {
|
||||||
tableWidth = 40
|
tableWidth = 40
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user