During a recent CTF challenge I had changed my laptop's power settings to not go to sleep while on battery. Of course, I forgot to change it back. So after it being unplugged all night it was as dead as a doorknob this morning.
I plugged it in, powered on, and fired up VS Code to keep hacking away at things. However, at the moment the laptop died I had about 10 separate VS Code windows with 5-10 files open in each. This is exactly what VS Code wanted to open again, all at once, and things were not going well.
The only other apps running were a terminal window and Chrome with 44 tabs...nothing right? I mean a Pixelbook Go i7 with 16GB of memory should be able to handle that 🤷
Regardless, I would prefer VS Code not remembering everything that was open on a cold start. It is also worth mentioning that I have Auto Save on.
stackoverflow, ftw
Thanks to this very underrated answer I was able to quickly get back to business.
I created ~/.vscode/tasks.json
and ~/.vscode/launch
as follows:
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "clear-editor-history",
"command": "${command:workbench.action.clearEditorHistory}"
}
]
}
launch
{
"version": "0.2.0",
"configurations": [
{
"preLaunchTask": "clear-editor-history"
}
]
}
Relaunch
Because of the unstable state VS Code was in I went ahead and rebooted my machine, but now VS Code only launches what I ask it to. For added sugar, recent projects can still be found under Recent in the Welcome tab 😉
Conclusion
Not a technically riveting article, but it was something that got me out of a tight spot, offered as an unaccepted answer in Stack Overflow.
Hopefully this short article helps someone in a similar predicament, and if it does, please up-vote the Stack Overflow answer to which we're crediting this solution to.
Top comments (0)