chore: generate
This commit is contained in:
@@ -74,7 +74,13 @@ export function DiffViewerFileTree(props: DiffViewerFileTreeProps) {
|
|||||||
{`${" ".repeat(row.depth)}${row.kind === "directory" ? (props.expandedNodes && !props.expandedNodes.has(row.id) ? "▸ " : "▾ ") : " "}`}
|
{`${" ".repeat(row.depth)}${row.kind === "directory" ? (props.expandedNodes && !props.expandedNodes.has(row.id) ? "▸ " : "▾ ") : " "}`}
|
||||||
</text>
|
</text>
|
||||||
<text
|
<text
|
||||||
fg={highlighted() ? props.theme.background : row.kind === "directory" ? props.theme.textMuted : props.theme.text}
|
fg={
|
||||||
|
highlighted()
|
||||||
|
? props.theme.background
|
||||||
|
: row.kind === "directory"
|
||||||
|
? props.theme.textMuted
|
||||||
|
: props.theme.text
|
||||||
|
}
|
||||||
bg={highlighted() ? props.theme.primary : undefined}
|
bg={highlighted() ? props.theme.primary : undefined}
|
||||||
wrapMode="none"
|
wrapMode="none"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ export type InternalTuiPlugin = Omit<TuiPluginModule, "id"> & {
|
|||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export function internalTuiPlugins(flags: Pick<RuntimeFlags.Info, "diffViewer" | "experimentalEventSystem">): InternalTuiPlugin[] {
|
export function internalTuiPlugins(
|
||||||
|
flags: Pick<RuntimeFlags.Info, "diffViewer" | "experimentalEventSystem">,
|
||||||
|
): InternalTuiPlugin[] {
|
||||||
return [
|
return [
|
||||||
HomeFooter,
|
HomeFooter,
|
||||||
HomeTips,
|
HomeTips,
|
||||||
|
|||||||
@@ -76,28 +76,22 @@ describe("diff viewer file tree utilities", () => {
|
|||||||
|
|
||||||
test("flattens all-expanded rows depth-first with depths and file references", () => {
|
test("flattens all-expanded rows depth-first with depths and file references", () => {
|
||||||
const rows = flattenFileTree(
|
const rows = flattenFileTree(
|
||||||
buildFileTree([
|
buildFileTree([{ file: "src/config/tui.ts" }, { file: "src/config/keybind.ts" }, { file: "README.md" }]),
|
||||||
{ file: "src/config/tui.ts" },
|
|
||||||
{ file: "src/config/keybind.ts" },
|
|
||||||
{ file: "README.md" },
|
|
||||||
]),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(rows.map((row) => ({ name: row.name, kind: row.kind, depth: row.depth, fileIndex: row.fileIndex }))).toEqual([
|
expect(rows.map((row) => ({ name: row.name, kind: row.kind, depth: row.depth, fileIndex: row.fileIndex }))).toEqual(
|
||||||
{ name: "src", kind: "directory", depth: 0, fileIndex: undefined },
|
[
|
||||||
{ name: "config", kind: "directory", depth: 1, fileIndex: undefined },
|
{ name: "src", kind: "directory", depth: 0, fileIndex: undefined },
|
||||||
{ name: "keybind.ts", kind: "file", depth: 2, fileIndex: 1 },
|
{ name: "config", kind: "directory", depth: 1, fileIndex: undefined },
|
||||||
{ name: "tui.ts", kind: "file", depth: 2, fileIndex: 0 },
|
{ name: "keybind.ts", kind: "file", depth: 2, fileIndex: 1 },
|
||||||
{ name: "README.md", kind: "file", depth: 0, fileIndex: 2 },
|
{ name: "tui.ts", kind: "file", depth: 2, fileIndex: 0 },
|
||||||
])
|
{ name: "README.md", kind: "file", depth: 0, fileIndex: 2 },
|
||||||
|
],
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("flattens only expanded directory descendants when expansion is provided", () => {
|
test("flattens only expanded directory descendants when expansion is provided", () => {
|
||||||
const tree = buildFileTree([
|
const tree = buildFileTree([{ file: "src/config/tui.ts" }, { file: "src/session/index.ts" }, { file: "README.md" }])
|
||||||
{ file: "src/config/tui.ts" },
|
|
||||||
{ file: "src/session/index.ts" },
|
|
||||||
{ file: "README.md" },
|
|
||||||
])
|
|
||||||
const src = tree.nodes.find((node) => node.kind === "directory" && node.name === "src")!
|
const src = tree.nodes.find((node) => node.kind === "directory" && node.name === "src")!
|
||||||
const config = tree.nodes.find((node) => node.kind === "directory" && node.name === "config")!
|
const config = tree.nodes.find((node) => node.kind === "directory" && node.name === "config")!
|
||||||
|
|
||||||
@@ -129,11 +123,7 @@ describe("diff viewer file tree utilities", () => {
|
|||||||
|
|
||||||
test("moves file selection relative to the highlighted row", () => {
|
test("moves file selection relative to the highlighted row", () => {
|
||||||
const rows = flattenFileTree(
|
const rows = flattenFileTree(
|
||||||
buildFileTree([
|
buildFileTree([{ file: "src/config/tui.ts" }, { file: "src/session/index.ts" }, { file: "README.md" }]),
|
||||||
{ file: "src/config/tui.ts" },
|
|
||||||
{ file: "src/session/index.ts" },
|
|
||||||
{ file: "README.md" },
|
|
||||||
]),
|
|
||||||
)
|
)
|
||||||
const config = rows.find((row) => row.kind === "directory" && row.name === "config")!
|
const config = rows.find((row) => row.kind === "directory" && row.name === "config")!
|
||||||
const session = rows.find((row) => row.kind === "directory" && row.name === "session")!
|
const session = rows.find((row) => row.kind === "directory" && row.name === "session")!
|
||||||
|
|||||||
@@ -45,26 +45,22 @@ describe("DiffViewerFileTree", () => {
|
|||||||
await app.renderOnce()
|
await app.renderOnce()
|
||||||
const lines = visibleLines(app.captureCharFrame())
|
const lines = visibleLines(app.captureCharFrame())
|
||||||
|
|
||||||
expect(lines).toEqual([
|
expect(lines).toEqual(["▾ a", " alpha.ts", " zeta.ts", "▾ b", " alpha.ts", " file.ts", " z-file.ts"])
|
||||||
"▾ a",
|
|
||||||
" alpha.ts",
|
|
||||||
" zeta.ts",
|
|
||||||
"▾ b",
|
|
||||||
" alpha.ts",
|
|
||||||
" file.ts",
|
|
||||||
" z-file.ts",
|
|
||||||
])
|
|
||||||
} finally {
|
} finally {
|
||||||
app.renderer.destroy()
|
app.renderer.destroy()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
test("keeps loading and error quiet while rendering an empty settled state", async () => {
|
test("keeps loading and error quiet while rendering an empty settled state", async () => {
|
||||||
const loading = await renderFrame(() => <DiffViewerFileTree files={[]} loading={true} error={undefined} theme={theme} />)
|
const loading = await renderFrame(() => (
|
||||||
|
<DiffViewerFileTree files={[]} loading={true} error={undefined} theme={theme} />
|
||||||
|
))
|
||||||
const failed = await renderFrame(() => (
|
const failed = await renderFrame(() => (
|
||||||
<DiffViewerFileTree files={[]} loading={false} error={new Error("nope")} theme={theme} />
|
<DiffViewerFileTree files={[]} loading={false} error={new Error("nope")} theme={theme} />
|
||||||
))
|
))
|
||||||
const empty = await renderFrame(() => <DiffViewerFileTree files={[]} loading={false} error={undefined} theme={theme} />)
|
const empty = await renderFrame(() => (
|
||||||
|
<DiffViewerFileTree files={[]} loading={false} error={undefined} theme={theme} />
|
||||||
|
))
|
||||||
|
|
||||||
expect(loading).not.toContain("Loading diff...")
|
expect(loading).not.toContain("Loading diff...")
|
||||||
expect(loading).not.toContain("No files")
|
expect(loading).not.toContain("No files")
|
||||||
@@ -79,7 +75,14 @@ describe("DiffViewerFileTree", () => {
|
|||||||
|
|
||||||
const focused = visibleLines(
|
const focused = visibleLines(
|
||||||
await renderFrame(() => (
|
await renderFrame(() => (
|
||||||
<DiffViewerFileTree files={files} loading={false} error={undefined} theme={theme} focused highlightedNode={src.id} />
|
<DiffViewerFileTree
|
||||||
|
files={files}
|
||||||
|
loading={false}
|
||||||
|
error={undefined}
|
||||||
|
theme={theme}
|
||||||
|
focused
|
||||||
|
highlightedNode={src.id}
|
||||||
|
/>
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
const unfocused = visibleLines(
|
const unfocused = visibleLines(
|
||||||
|
|||||||
Reference in New Issue
Block a user