mirror of
https://github.com/patriceckhart/zot.git
synced 2026-06-27 05:46:34 +02:00
fix: full-width extensions divider in slash command popup
len(label) counted bytes, but the leading "── " glyphs are multi-byte runes, so the rule was padded ~4 columns short of the right edge. Switched to runewidth.StringWidth(label) to match dialog_frame.go.
This commit is contained in:
parent
5293277d36
commit
66847247b3
1 changed files with 6 additions and 2 deletions
|
|
@ -4,6 +4,8 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/mattn/go-runewidth"
|
||||
|
||||
"github.com/patriceckhart/zot/internal/tui"
|
||||
)
|
||||
|
||||
|
|
@ -408,8 +410,10 @@ func (s *slashSuggester) Render(input string, th tui.Theme, width int) []string
|
|||
lines = append(lines, "")
|
||||
rule := strings.Repeat("─", width)
|
||||
label := "── " + c.Name + " "
|
||||
if len(label) < width {
|
||||
rule = label + strings.Repeat("─", width-len(label))
|
||||
// runewidth, not len: the leading "── " glyphs are multi-byte,
|
||||
// so byte-length padding leaves the rule short of the right edge.
|
||||
if lw := runewidth.StringWidth(label); lw < width {
|
||||
rule = label + strings.Repeat("─", width-lw)
|
||||
}
|
||||
lines = append(lines, th.FG256(th.Muted, rule))
|
||||
lines = append(lines, "")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue