From 6dc3cf2f3d0db7e99d28ee7d6d457a345c604915 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 23 Jul 2025 18:01:11 -0400 Subject: [PATCH] fix(tui): completions: readjust position on filter change --- .../tui/components/completions/completions.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/tui/components/completions/completions.go b/internal/tui/components/completions/completions.go index c034d0da4fefaa4731b8eb5899543134f13d1e52..e82dff1816f53e1467d3c18478eeeee9dbfbb856 100644 --- a/internal/tui/components/completions/completions.go +++ b/internal/tui/components/completions/completions.go @@ -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