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

tui: fix autocomplete display to prevent long file paths from breaking layout

Dax Raad 3 месяцев назад
Родитель
Сommit
ad83dd3ad9

+ 3 - 1
packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx

@@ -8,6 +8,7 @@ import { useSync } from "@tui/context/sync"
 import { useTheme } from "@tui/context/theme"
 import { SplitBorder } from "@tui/component/border"
 import { useCommandDialog } from "@tui/component/dialog-command"
+import { Locale } from "@/util/locale"
 import type { PromptInfo } from "./history"
 
 export type AutocompleteRef = {
@@ -125,10 +126,11 @@ export function Autocomplete(props: {
 
       // Add file options
       if (!result.error && result.data) {
+        const width = store.position.width - 4
         options.push(
           ...result.data.map(
             (item): AutocompleteOption => ({
-              display: item,
+              display: Locale.truncateMiddle(item, width),
               onSelect: () => {
                 insertPart(item, {
                   type: "file",