forked from docker/docker-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompletion.go
More file actions
35 lines (29 loc) · 1.11 KB
/
completion.go
File metadata and controls
35 lines (29 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package completions
import (
"context"
"github.com/docker/docker-agent/pkg/app"
"github.com/docker/docker-agent/pkg/tui/components/completion"
)
type Completion interface {
Trigger() string
Items() []completion.Item
RequiresEmptyEditor() bool
// MatchMode returns how items should be filtered (fuzzy or prefix)
MatchMode() completion.MatchMode
}
// AsyncLoader is an optional interface for completions that support async loading.
// This allows the editor to load items in the background without blocking the UI.
type AsyncLoader interface {
// LoadInitialItemsAsync loads a shallow set of items quickly (e.g., 2 levels deep, ~100 files).
// Returns a channel that receives initial items for immediate display.
LoadInitialItemsAsync(ctx context.Context) <-chan []completion.Item
// LoadItemsAsync loads all items in a background goroutine with context support.
// It returns a channel that receives the items when loading is complete.
LoadItemsAsync(ctx context.Context) <-chan []completion.Item
}
func Completions(a *app.App) []Completion {
return []Completion{
NewCommandCompletion(a),
NewFileCompletion(),
}
}