mirror of
https://github.com/github/awesome-copilot.git
synced 2026-09-17 12:21:22 +00:00
Add Windows app storage inspector canvas 🤖🤖🤖 (#2620)
* feat: add Windows app storage inspector canvas * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix: address storage inspector review findings * Correction to package and plugin * fix: harden storage inspector cleanup * Harden cleanup operation outcomes * Add select a file or folder path in the result tabs to navigate the treemap to its deepest visible parent folder. * Fixes to ensure selftesst pass --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
parent
5755234c4f
commit
df9116a689
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
||||
export function normalizePath(value) {
|
||||
return String(value ?? "")
|
||||
.replaceAll("/", "\\")
|
||||
.replace(/\\+$/, "")
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
export function containsPath(parentPath, targetPath) {
|
||||
const parent = normalizePath(parentPath);
|
||||
const target = normalizePath(targetPath);
|
||||
return parent === "" || target === parent || target.startsWith(`${parent}\\`);
|
||||
}
|
||||
|
||||
export function getParentPath(value) {
|
||||
const path = String(value ?? "").replaceAll("/", "\\").replace(/\\+$/, "");
|
||||
const separatorIndex = path.lastIndexOf("\\");
|
||||
if (separatorIndex < 0) {
|
||||
return path;
|
||||
}
|
||||
return separatorIndex === 2 ? path.slice(0, separatorIndex + 1) : path.slice(0, separatorIndex);
|
||||
}
|
||||
|
||||
export function findTreeStackForPath(tree, targetPath) {
|
||||
if (!tree || !normalizePath(targetPath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const stack = [tree];
|
||||
let node = tree;
|
||||
while (true) {
|
||||
const child = node.children?.find((item) => !item.aggregate && containsPath(item.path, targetPath));
|
||||
if (!child) {
|
||||
return stack;
|
||||
}
|
||||
stack.push(child);
|
||||
node = child;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user