mirror of
https://github.com/stablyai/orca.git
synced 2026-10-01 16:02:03 +00:00
fix(renderer): preserve collapsed combined-diff tree boundaries
This commit is contained in:
+7
-1
@@ -131,7 +131,13 @@ export function getViewedCombinedDiffTreeVisibility({
|
||||
}
|
||||
const names = [projected.source.name]
|
||||
let compacted = projected
|
||||
while (compacted.children.length === 1 && compacted.children[0]?.source.type === 'directory') {
|
||||
// Keep a collapsed directory as a visible boundary; filtering must not compact it away and
|
||||
// accidentally expose descendants that the user explicitly hid.
|
||||
while (
|
||||
!collapsedDirectoryKeys.has(compacted.source.key) &&
|
||||
compacted.children.length === 1 &&
|
||||
compacted.children[0]?.source.type === 'directory'
|
||||
) {
|
||||
compacted = compacted.children[0]
|
||||
names.push(compacted.source.name)
|
||||
}
|
||||
|
||||
+23
@@ -192,4 +192,27 @@ describe('CombinedDiffFileTree navigation mapping', () => {
|
||||
})
|
||||
expect(compactedDirectory && visibility.visibleFileCounts.get(compactedDirectory.key)).toBe(1)
|
||||
})
|
||||
|
||||
it('preserves a collapsed directory boundary while filtering viewed siblings', () => {
|
||||
const entries: GitBranchChangeEntry[] = [
|
||||
{ path: 'src/a/one.ts', status: 'modified' },
|
||||
{ path: 'src/b/two.ts', status: 'modified' }
|
||||
]
|
||||
const roots = buildCombinedDiffBranchTreeRoots('branch', entries)
|
||||
const visibility = getViewedCombinedDiffTreeVisibility({
|
||||
roots,
|
||||
collapsedDirectoryKeys: new Set(['dir::combined-branch::src']),
|
||||
mode: 'branch',
|
||||
viewedSectionKeys: new Set(['combined-branch:src/b/two.ts'])
|
||||
})
|
||||
|
||||
expect(visibility.rows).toEqual([
|
||||
expect.objectContaining({
|
||||
type: 'directory',
|
||||
key: 'dir::combined-branch::src',
|
||||
path: 'src'
|
||||
})
|
||||
])
|
||||
expect(visibility.visibleFileCount).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user