@@ -29,6 +29,11 @@ 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+
3237// Completions represents the completions popup component.
3338type Completions struct {
3439 // Popup dimensions
@@ -88,10 +93,12 @@ func (c *Completions) KeyMap() KeyMap {
8893}
8994
9095// OpenWithFiles opens the completions with file items from the filesystem.
91−func (c *Completions) OpenWithFiles(depth, limit int) {
92− files, _, _ := fsext.ListDirectory(".", nil, depth, limit)
93− slices.Sort(files)
94− c.SetFiles(files)
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+ }
95102}
96103
97104// SetFiles sets the file items on the completions popup.