@@ -29,11 +29,6 @@ type SelectionMsg struct {
2929// ClosedMsg is sent when the completions are closed.
3030type ClosedMsg struct{}
3131
32−// FilesLoadedMsg is sent when files have been loaded for completions.
33−type FilesLoadedMsg struct {
34− Files []string
35−}
36−
3732// Completions represents the completions popup component.
3833type Completions struct {
3934 // Popup dimensions
@@ -93,12 +88,10 @@ func (c *Completions) KeyMap() KeyMap {
9388}
9489
9590// OpenWithFiles opens the completions with file items from the filesystem.
96−func (c *Completions) OpenWithFiles(depth, limit int) tea.Cmd {
97− return func() tea.Msg {
98− files, _, _ := fsext.ListDirectory(".", nil, depth, limit)
99− slices.Sort(files)
100− return FilesLoadedMsg{Files: files}
101− }
91+func (c *Completions) OpenWithFiles(depth, limit int) {
92+ files, _, _ := fsext.ListDirectory(".", nil, depth, limit)
93+ slices.Sort(files)
94+ c.SetFiles(files)
10295}
10396
10497// SetFiles sets the file items on the completions popup.
@@ -133,11 +126,9 @@ func (c *Completions) SetFiles(files []string) {
133126}
134127
135128// Close closes the completions popup.
136−func (c *Completions) Close() tea.Cmd {
129+func (c *Completions) Close() tea.Msg {
137130 c.open = false
138− return func() tea.Msg {
139− return ClosedMsg{}
140− }
131+ return ClosedMsg{}
141132}
142133
143134// Filter filters the completions with the given query.
@@ -171,7 +162,7 @@ func (c *Completions) HasItems() bool {
171162}
172163
173164// 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) {
175166 if !c.open {
176167 return nil, false
177168 }
@@ -228,7 +219,7 @@ func (c *Completions) selectNext() {
228219}
229220
230221// 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 {
232223 items := c.list.VisibleItems()
233224 if len(items) == 0 {
234225 return nil
@@ -248,11 +239,9 @@ func (c *Completions) selectCurrent(insert bool) tea.Cmd {
248239 c.open = false
249240 }
250241
251− return func() tea.Msg {
252− return SelectionMsg{
253− Value: item.Value(),
254− Insert: insert,
255− }
242+ return SelectionMsg{
243+ Value: item.Value(),
244+ Insert: insert,
256245 }
257246}
258247