fix(webui): re-checking a partial folder clears its descendant exclusions
This commit is contained in:
@@ -74,6 +74,16 @@ describe("workspaceSelection", () => {
|
||||
expect(uncheck(sel, "other.txt")).toBe(sel);
|
||||
});
|
||||
|
||||
it("re-checking an indeterminate folder clears all its exclusions", () => {
|
||||
let sel = check(emptySelection(), "dir");
|
||||
sel = uncheck(sel, "dir/a.txt");
|
||||
sel = uncheck(sel, "dir/sub");
|
||||
sel = check(sel, "dir");
|
||||
expect(isChecked(sel, "dir")).toBe(true);
|
||||
expect(isIndeterminate(sel, "dir")).toBe(false);
|
||||
expect([...sel.excluded]).toEqual([]);
|
||||
});
|
||||
|
||||
it("produces sorted include/exclude params", () => {
|
||||
let sel = check(emptySelection(), "z.txt");
|
||||
sel = check(sel, "dir");
|
||||
|
||||
@@ -61,11 +61,13 @@ export function check(
|
||||
): WorkspaceSelection {
|
||||
if (isChecked(sel, path)) return sel;
|
||||
if (coveredBy(sel.checked, path)) {
|
||||
// Covered by a collapsed ancestor but excluded. Only a DIRECT exclusion
|
||||
// entry on `path` itself can be cleared by re-checking; an exclusion on a
|
||||
// strict ancestor (e.g. `dir/sub` while checking `dir/sub/c.txt`) keeps
|
||||
// the path excluded.
|
||||
if (!sel.excluded.has(path)) return sel;
|
||||
// Covered by a collapsed ancestor. Re-checking clears exclusions on
|
||||
// `path` itself (re-selecting an excluded child) AND on its descendants
|
||||
// (clicking an indeterminate folder upgrades it to fully checked). An
|
||||
// exclusion on a strict ANCESTOR (e.g. `dir/sub` while checking
|
||||
// `dir/sub/c.txt`) is untouched — that path stays excluded.
|
||||
if (!sel.excluded.has(path) && !hasDescendant(sel.excluded, path))
|
||||
return sel;
|
||||
return {
|
||||
checked: sel.checked,
|
||||
excluded: withoutSubtree(sel.excluded, path),
|
||||
|
||||
Reference in New Issue
Block a user