Просмотр исходного кода

fix(ui): use full file path for fuzzy matching in autocomplete (#6705)

Co-authored-by: Aiden Cline <[email protected]>
Aleksandr Bagatka 1 месяц назад
Родитель
Сommit
f6fc693c1f
1 измененных файлов с 10 добавлено и 2 удалено
  1. 10 2
      packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx

+ 10 - 2
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]