@@ -29,6 +29,11 @@ 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 {
32// Completions represents the completions popup component.
37// Completions represents the completions popup component.
33type Completions struct {
38type Completions struct {
34 // Popup dimensions
39 // Popup dimensions
@@ -88,10 +93,12 @@ func (c *Completions) KeyMap() KeyMap {
90// OpenWithFiles opens the completions with file items from the filesystem.
95// OpenWithFiles opens the completions with file items from the filesystem.
91−func (c *Completions) OpenWithFiles(depth, limit int) {
96+func (c *Completions) OpenWithFiles(depth, limit int) tea.Cmd {
97+ return func() tea.Msg {
92− files, _, _ := fsext.ListDirectory(".", nil, depth, limit)
98+ files, _, _ := fsext.ListDirectory(".", nil, depth, limit)
93− slices.Sort(files)
99+ slices.Sort(files)
94− c.SetFiles(files)
100+ return FilesLoadedMsg{Files: files}
97// SetFiles sets the file items on the completions popup.
104// SetFiles sets the file items on the completions popup.