diff options
| author | Sebastian Herrlinger <[email protected]> | 2025-12-23 12:22:34 +0100 |
|---|---|---|
| committer | Sebastian Herrlinger <[email protected]> | 2025-12-23 12:22:34 +0100 |
| commit | c352999b4163252d753db21b7d03cf1ebd2a35bc (patch) | |
| tree | 5fb9d89a62b65186222e9861ad870f117c27a4bb /packages | |
| parent | f4cd708ca06a8ff667e469bb4dc07460b612f92d (diff) | |
| download | opencode-c352999b4163252d753db21b7d03cf1ebd2a35bc.tar.gz opencode-c352999b4163252d753db21b7d03cf1ebd2a35bc.zip | |
no intermediate autocomplete result to avoid flickering
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx index b2221a3b6..cef083ad7 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx @@ -364,12 +364,25 @@ export function Autocomplete(props: { })) }) - const options = createMemo(() => { + const options = createMemo((prev: AutocompleteOption[] | undefined) => { + const filesValue = files() + const agentsValue = agents() + const commandsValue = commands() + const mixed: AutocompleteOption[] = ( - store.visible === "@" ? [...agents(), ...(files() || [])] : [...commands()] + store.visible === "@" ? [...agentsValue, ...(filesValue || [])] : [...commandsValue] ).filter((x) => x.disabled !== true) + const currentFilter = filter() - if (!currentFilter) return mixed + + if (!currentFilter) { + return mixed + } + + if (files.loading && prev && prev.length > 0) { + return prev + } + const result = fuzzysort.go(currentFilter, mixed, { keys: [(obj) => obj.display.trimEnd(), "description", (obj) => obj.aliases?.join(" ") ?? ""], limit: 10, @@ -381,6 +394,7 @@ export function Autocomplete(props: { return objResults.score }, }) + return result.map((arr) => arr.obj) }) |
