mirror of
https://github.com/charmbracelet/crush.git
synced 2025-08-02 05:20:46 +03:00
fix(tui): completions: readjust position on filter change
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user