fix(tui): completions: readjust position on filter change

This commit is contained in:
Ayman Bagabas
2025-07-23 18:01:11 -04:00
parent fd1adf07e6
commit 6dc3cf2f3d

View File

@@ -51,13 +51,14 @@ type Completions interface {
}
type completionsCmp struct {
wWidth int // The window width
width int
height int // Height of the completions component`
x, xorig int // X position for the completions popup
y int // Y position for the completions popup
open bool // Indicates if the completions are open
keyMap KeyMap
wWidth int // The window width
width int
lastWidth int
height int // Height of the completions component`
x, xorig int // X position for the completions popup
y int // Y position for the completions popup
open bool // Indicates if the completions are open
keyMap KeyMap
list list.ListModel
query string // The current filter query
@@ -210,7 +211,8 @@ func (c *completionsCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
items := c.list.Items()
itemsLen := len(items)
width := listWidth(items)
if c.x < 0 {
c.lastWidth = c.width
if c.x < 0 || width < c.lastWidth {
c.x = c.xorig
} else if c.x+width >= c.wWidth {
c.x = c.wWidth - width - 1