@@ -51,13 +51,14 @@ type Completions interface {
5151}
5252
5353type completionsCmp struct {
54− wWidth int // The window width
55− width int
56− height int // Height of the completions component`
57− x, xorig int // X position for the completions popup
58− y int // Y position for the completions popup
59− open bool // Indicates if the completions are open
60− keyMap KeyMap
54+ wWidth int // The window width
55+ width int
56+ lastWidth int
57+ height int // Height of the completions component`
58+ x, xorig int // X position for the completions popup
59+ y int // Y position for the completions popup
60+ open bool // Indicates if the completions are open
61+ keyMap KeyMap
6162
6263 list list.ListModel
6364 query string // The current filter query
@@ -210,7 +211,8 @@ func (c *completionsCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
210211 items := c.list.Items()
211212 itemsLen := len(items)
212213 width := listWidth(items)
213− if c.x < 0 {
214+ c.lastWidth = c.width
215+ if c.x < 0 || width < c.lastWidth {
214216 c.x = c.xorig
215217 } else if c.x+width >= c.wWidth {
216218 c.x = c.wWidth - width - 1