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

This commit is contained in:
Dax Raad
2025-11-11 21:35:13 -05:00
committed by opencode
parent 6f37315cd1
commit ad83dd3ad9

View File

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