mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-21 17:54:23 +01:00
tui: fix autocomplete display to prevent long file paths from breaking layout
This commit is contained in:
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user