Skip to content

Instantly share code, notes, and snippets.

@ricklamers
Last active September 25, 2021 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricklamers/a7141343fd1a6037aaa1a0e6a81f19ac to your computer and use it in GitHub Desktop.
Save ricklamers/a7141343fd1a6037aaa1a0e6a81f19ac to your computer and use it in GitHub Desktop.
Expand all folders in VS Code (run in console)
function getUnexpandedListItems() {
return document.querySelectorAll(".monaco-list-row[aria-expanded=false]");
}
function expandItems(items) {
for (let item of items) {
item.click();
}
}
let nothingFoundFrequency = 0;
let interval = setInterval(() => {
let items = getUnexpandedListItems();
if (items.length > 0) {
nothingFoundFrequency = 0;
expandItems(items);
} else {
nothingFoundFrequency += 1;
// Try 1000 times (>= 1 second) because perhaps
// the unfolding is still "settling".
if (nothingFoundFrequency > 1000) {
clearInterval(interval);
console.log("Done unfolding.");
}
}
}, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment