diff options
| author | Aleksandr Bagatka <[email protected]> | 2026-01-08 23:43:05 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-08 16:43:05 -0600 |
| commit | f6fc693c1f15d42fae2869c1f61df244a51e51a7 (patch) | |
| tree | f741468804133599a91fb5809b3ef19e027e17c6 | |
| parent | 50d8396c9af59f242d26d03693c24aa606a185f9 (diff) | |
| download | opencode-f6fc693c1f15d42fae2869c1f61df244a51e51a7.tar.gz opencode-f6fc693c1f15d42fae2869c1f61df244a51e51a7.zip | |
fix(ui): use full file path for fuzzy matching in autocomplete (#6705)
Co-authored-by: Aiden Cline <[email protected]>
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx | 12 |
1 files changed, 10 insertions, 2 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 57eac9544..3c757f81b 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx @@ -53,6 +53,7 @@ export type AutocompleteRef = { export type AutocompleteOption = { display: string + value?: string aliases?: string[] disabled?: boolean description?: string @@ -221,6 +222,7 @@ export function Autocomplete(props: { const isDir = item.endsWith("/") return { display: Locale.truncateMiddle(filename, width), + value: filename, isDirectory: isDir, path: item, onSelect: () => { @@ -259,8 +261,10 @@ export function Autocomplete(props: { const width = props.anchor().width - 4 for (const res of Object.values(sync.data.mcp_resource)) { + const text = `${res.name} (${res.uri})` options.push({ - display: Locale.truncateMiddle(`${res.name} (${res.uri})`, width), + display: Locale.truncateMiddle(text, width), + value: text, description: res.description, onSelect: () => { insertPart(res.name, { @@ -485,7 +489,11 @@ export function Autocomplete(props: { } const result = fuzzysort.go(removeLineRange(currentFilter), mixed, { - keys: [(obj) => removeLineRange(obj.display.trimEnd()), "description", (obj) => obj.aliases?.join(" ") ?? ""], + keys: [ + (obj) => removeLineRange((obj.value ?? obj.display).trimEnd()), + "description", + (obj) => obj.aliases?.join(" ") ?? "", + ], limit: 10, scoreFn: (objResults) => { const displayResult = objResults[0] |
