mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-30 08:10:23 +00:00
chore: generate
This commit is contained in:
@@ -179,11 +179,7 @@ export function orderedPatchFileIndexes(rows: readonly FileTreeRow[]) {
|
|||||||
return rows.flatMap((row) => (row.fileIndex === undefined ? [] : [row.fileIndex]))
|
return rows.flatMap((row) => (row.fileIndex === undefined ? [] : [row.fileIndex]))
|
||||||
}
|
}
|
||||||
|
|
||||||
export function movePatchFileIndex(
|
export function movePatchFileIndex(fileIndexes: readonly number[], current: number | undefined, offset: number) {
|
||||||
fileIndexes: readonly number[],
|
|
||||||
current: number | undefined,
|
|
||||||
offset: number,
|
|
||||||
) {
|
|
||||||
if (fileIndexes.length === 0) return undefined
|
if (fileIndexes.length === 0) return undefined
|
||||||
const index = current === undefined ? -1 : fileIndexes.indexOf(current)
|
const index = current === undefined ? -1 : fileIndexes.indexOf(current)
|
||||||
if (index === -1) return offset < 0 ? fileIndexes[fileIndexes.length - 1] : fileIndexes[0]
|
if (index === -1) return offset < 0 ? fileIndexes[fileIndexes.length - 1] : fileIndexes[0]
|
||||||
|
|||||||
@@ -239,14 +239,12 @@ describe("diff viewer file tree utilities", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test("selects a file tree node and expands its parents for a patch file", () => {
|
test("selects a file tree node and expands its parents for a patch file", () => {
|
||||||
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 selection = fileTreeFileSelection(tree, 1)
|
const selection = fileTreeFileSelection(tree, 1)
|
||||||
|
|
||||||
expect(selection?.highlightedNode).toBe(tree.nodes.find((node) => node.kind === "file" && node.name === "index.ts")?.id)
|
expect(selection?.highlightedNode).toBe(
|
||||||
|
tree.nodes.find((node) => node.kind === "file" && node.name === "index.ts")?.id,
|
||||||
|
)
|
||||||
expect([...selection!.expandedNodes].map((id) => tree.nodes[id]!.name)).toEqual(["session", "src"])
|
expect([...selection!.expandedNodes].map((id) => tree.nodes[id]!.name)).toEqual(["session", "src"])
|
||||||
expect(fileTreeFileSelection(tree, 99)).toBeUndefined()
|
expect(fileTreeFileSelection(tree, 99)).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user