tui: truncate sidebar file paths (#30531)
This commit is contained in:
parent
b6f76e29c5
commit
06eecc5a6d
1 changed files with 8 additions and 1 deletions
|
|
@ -1,9 +1,16 @@
|
||||||
import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui"
|
import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui"
|
||||||
import type { InternalTuiPlugin } from "../../plugin/internal"
|
import type { InternalTuiPlugin } from "../../plugin/internal"
|
||||||
import { createMemo, For, Show, createSignal } from "solid-js"
|
import { createMemo, For, Show, createSignal } from "solid-js"
|
||||||
|
import { Locale } from "@/util/locale"
|
||||||
|
|
||||||
const id = "internal:sidebar-files"
|
const id = "internal:sidebar-files"
|
||||||
|
|
||||||
|
function changeCountWidth(item: { additions: number; deletions: number }) {
|
||||||
|
return [item.additions ? `+${item.additions}` : "", item.deletions ? `-${item.deletions}` : ""]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" ").length
|
||||||
|
}
|
||||||
|
|
||||||
function View(props: { api: TuiPluginApi; session_id: string }) {
|
function View(props: { api: TuiPluginApi; session_id: string }) {
|
||||||
const [open, setOpen] = createSignal(true)
|
const [open, setOpen] = createSignal(true)
|
||||||
const theme = () => props.api.theme.current
|
const theme = () => props.api.theme.current
|
||||||
|
|
@ -25,7 +32,7 @@ function View(props: { api: TuiPluginApi; session_id: string }) {
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<box flexDirection="row" gap={1} justifyContent="space-between">
|
<box flexDirection="row" gap={1} justifyContent="space-between">
|
||||||
<text fg={theme().textMuted} wrapMode="none">
|
<text fg={theme().textMuted} wrapMode="none">
|
||||||
{item.file}
|
{Locale.truncateLeft(item.file, Math.max(2, 36 - changeCountWidth(item)))}
|
||||||
</text>
|
</text>
|
||||||
<box flexDirection="row" gap={1} flexShrink={0}>
|
<box flexDirection="row" gap={1} flexShrink={0}>
|
||||||
<Show when={item.additions}>
|
<Show when={item.additions}>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue