@@ -29,11 +29,6 @@ type SelectionMsg struct {
29// ClosedMsg is sent when the completions are closed.
29// ClosedMsg is sent when the completions are closed.
30type ClosedMsg struct{}
30type ClosedMsg struct{}
32−// FilesLoadedMsg is sent when files have been loaded for completions.
33−type FilesLoadedMsg struct {
37// Completions represents the completions popup component.
32// Completions represents the completions popup component.
38type Completions struct {
33type Completions struct {
39 // Popup dimensions
34 // Popup dimensions
@@ -93,12 +88,10 @@ func (c *Completions) KeyMap() KeyMap {
95// OpenWithFiles opens the completions with file items from the filesystem.
90// OpenWithFiles opens the completions with file items from the filesystem.
96−func (c *Completions) OpenWithFiles(depth, limit int) tea.Cmd {
91+func (c *Completions) OpenWithFiles(depth, limit int) {
97− return func() tea.Msg {
98− files, _, _ := fsext.ListDirectory(".", nil, depth, limit)
92+ files, _, _ := fsext.ListDirectory(".", nil, depth, limit)
99− slices.Sort(files)
93+ slices.Sort(files)
100− return FilesLoadedMsg{Files: files}
94+ c.SetFiles(files)
104// SetFiles sets the file items on the completions popup.
97// SetFiles sets the file items on the completions popup.
@@ -133,11 +126,9 @@ func (c *Completions) SetFiles(files []string) {
135// Close closes the completions popup.
128// Close closes the completions popup.
136−func (c *Completions) Close() tea.Cmd {
129+func (c *Completions) Close() tea.Msg {
137 c.open = false
130 c.open = false
138− return func() tea.Msg {
139− return ClosedMsg{}
131+ return ClosedMsg{}
143// Filter filters the completions with the given query.
134// Filter filters the completions with the given query.
@@ -171,7 +162,7 @@ func (c *Completions) HasItems() bool {
173// Update handles key events for the completions.
164// Update handles key events for the completions.
174−func (c *Completions) Update(msg tea.KeyPressMsg) (tea.Cmd, bool) {
165+func (c *Completions) Update(msg tea.KeyPressMsg) (tea.Msg, bool) {
175 if !c.open {
166 if !c.open {
176 return nil, false
167 return nil, false
@@ -228,7 +219,7 @@ func (c *Completions) selectNext() {
230// selectCurrent returns a command with the currently selected item.
221// selectCurrent returns a command with the currently selected item.
231−func (c *Completions) selectCurrent(insert bool) tea.Cmd {
222+func (c *Completions) selectCurrent(insert bool) tea.Msg {
232 items := c.list.VisibleItems()
223 items := c.list.VisibleItems()
233 if len(items) == 0 {
224 if len(items) == 0 {
234 return nil
225 return nil
@@ -248,11 +239,9 @@ func (c *Completions) selectCurrent(insert bool) tea.Cmd {
248 c.open = false
239 c.open = false
251− return func() tea.Msg {
252− return SelectionMsg{
242+ return SelectionMsg{
253− Value: item.Value(),
243+ Value: item.Value(),
254− Insert: insert,
244+ Insert: insert,