mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-01-11 14:38:10 +03:00
fix(table): append headers/columns to zero sized string slice
This commit is contained in:
parent
278edd1c2b
commit
13f52d678d
@ -346,7 +346,7 @@ func (m *Model) FromValues(value, separator string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m Model) headersView() string {
|
func (m Model) headersView() string {
|
||||||
var s = make([]string, len(m.cols))
|
var s = make([]string, 0, len(m.cols))
|
||||||
for _, col := range m.cols {
|
for _, col := range m.cols {
|
||||||
style := lipgloss.NewStyle().Width(col.Width).MaxWidth(col.Width).Inline(true)
|
style := lipgloss.NewStyle().Width(col.Width).MaxWidth(col.Width).Inline(true)
|
||||||
renderedCell := style.Render(runewidth.Truncate(col.Title, col.Width, "…"))
|
renderedCell := style.Render(runewidth.Truncate(col.Title, col.Width, "…"))
|
||||||
@ -356,7 +356,7 @@ func (m Model) headersView() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) renderRow(rowID int) string {
|
func (m *Model) renderRow(rowID int) string {
|
||||||
var s = make([]string, len(m.cols))
|
var s = make([]string, 0, len(m.cols))
|
||||||
for i, value := range m.rows[rowID] {
|
for i, value := range m.rows[rowID] {
|
||||||
style := lipgloss.NewStyle().Width(m.cols[i].Width).MaxWidth(m.cols[i].Width).Inline(true)
|
style := lipgloss.NewStyle().Width(m.cols[i].Width).MaxWidth(m.cols[i].Width).Inline(true)
|
||||||
renderedCell := m.styles.Cell.Render(style.Render(runewidth.Truncate(value, m.cols[i].Width, "…")))
|
renderedCell := m.styles.Cell.Render(style.Render(runewidth.Truncate(value, m.cols[i].Width, "…")))
|
||||||
|
Loading…
Reference in New Issue
Block a user