The open source coding agent.
TypeScript
fix(ui): use full file path for fuzzy matching in autocomplete (#6705)
Aleksandr Bagatkaf6fc693c1f15
diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsxindex 57eac9544e6..3c757f81b18 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?: stringaliases?: string[]disabled?: booleandescription?: 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 - 4for (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]