on main help sign in
fix(ui): completions popup gets too narrow on single item (#2125)

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

commitb28f4ced49e4ce5c76446a9ee3e3fcd90adac744 authorCarlos Alexandro Becker <caarlos0@users.noreply.github.com> dateWed 4 Feb 2026, 17:07 (8 months ago) parentd558340
1 file changed+9−15
internal/ui/completions/completions.go+9−15
internal/ui/completions/completions.go+9−15
@@ -128,16 +128,7 @@ func (c *Completions) SetFiles(files []string) {
128128 c.list.SelectFirst()
129129 c.list.ScrollToSelected()
130130
131− // recalculate width by using just the visible items
132− start, end := c.list.VisibleItemIndices()
133− width := 0
134− if end != 0 {
135− for _, file := range files[start : end+1] {
136− width = max(width, ansi.StringWidth(file))
137− }
138− }
139− c.width = ordered.Clamp(width+2, int(minWidth), int(maxWidth))
140− c.list.SetSize(c.width, c.height)
131+ c.updateSize()
141132}
142133
143134// Close closes the completions popup.
@@ -158,14 +149,17 @@ func (c *Completions) Filter(query string) {
158149 c.query = query
159150 c.list.SetFilter(query)
160151
161− // recalculate width by using just the visible items
152+ c.updateSize()
153+}
154+
155+func (c *Completions) updateSize() {
162156 items := c.list.FilteredItems()
163157 start, end := c.list.VisibleItemIndices()
164158 width := 0
165− if end != 0 {
166− for _, item := range items[start : end+1] {
167− width = max(width, ansi.StringWidth(item.(interface{ Text() string }).Text()))
168− }
159+ for i := start; i <= end; i++ {
160+ item := c.list.ItemAt(i)
161+ s := item.(interface{ Text() string }).Text()
162+ width = max(width, ansi.StringWidth(s))
169163 }
170164 c.width = ordered.Clamp(width+2, int(minWidth), int(maxWidth))
171165 c.height = ordered.Clamp(len(items), int(minHeight), int(maxHeight))