Skip to content
Myr

fix(table): padding on item indicator (#841)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Carlos Alexandro Becker · committed by GitHub · parent ce6bb49 · Browse files · 1 file+20 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+20 added−1 removed

  • other:+20 added−1 removed

1 file+20 added−1 removed

modified:table/table.go+20 added-1 removed
14 unmodified lines
15package table1617import (18 "fmt"19 "strconv"2021 "github.com/charmbracelet/bubbles/help"22 "github.com/charmbracelet/bubbles/key"23 "github.com/charmbracelet/bubbles/table"
56 unmodified lines
80 if m.hideCount {81 return ""82 }8383 return m.help.Styles.FullDesc.Render(fmt.Sprintf("%d/%d%s", m.table.Cursor()+1, len(m.table.Rows()), m.help.ShortSeparator))84 padding := strconv.Itoa(numLen(len(m.table.Rows())))85 return m.help.Styles.FullDesc.Render(fmt.Sprintf(86 "%"+padding+"d/%d%s",87 m.table.Cursor()+1,88 len(m.table.Rows()),89 m.help.ShortSeparator,90 ))91}9293func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {94 var cmd tea.Cmd
28 unmodified lines
123 s += "\n" + m.countView() + m.help.View(m.keymap)124 }125 return s126}127128func numLen(i int) int {129 if i == 0 {130 return 1131 }132 count := 0133 for i != 0 {134 i /= 10135 count++136 }137 return count138}