This morning I discovered a life-changing setting in VS Code to allow the command palette to stay open after the window loses focus.
tl;dr Use the
"workbench.quickOpen.closeOnFocusLost": falsesetting to avoid losing all your state when changing windows.
There are lots of reasons I dislike Excel, and lots of reasons I love it. One of the reasons I love it is the ability to be editing a cell, tab away, and when I tab back it’s exactly as I left it. Still editing the cell. Try it! That maintenance of state is a mental relief when using Excel.
As I was setting up the Salesforce Developer Experience (SFDX) and the accompanying VS Code extensions, there were several commands in the command palette that I had to execute that required multiple parameters.
For example, when creating a SFDX project, you execute the
SFDX: Create Project command. When you do, it asks you a series of questions, like which project template you would like, what the project name should be, etc.
This is great, if you know all of these values from memory. If, however, you’re trying to copy/paste the values from somewhere else, or reference a file path in Explorer, or if you’re following along with an online tutorial and need to alt+tab between applications, you will quickly find out that…
As soon as the command palette loses focus, it goes away, and all of the data you’ve typed in is…gone. So yes, it will make you try again, and type it all in from memory.
Believe me, I’ve gone through the re-type dance several times.
Which is why I decided to open an issue on the VS Code repo. This is super inconvenient - surely this needs to be fixed for the greater good!
After searching around a bit for this issue, I didn’t find anything, and ended up opening this issue, my own little piece of VS Code history.
Two days later, the response came back that there was actually a setting that controls this behavior! And since the setting uses the term “quick open” instead of “command palette,” I didn’t find it in my searching about.
So here’s the setting:
Just open up your VS Code preferences and search for this setting.
I tell you what, I am slotting that in as a user default setting on every instance of VS Code I use. I’m not sure why that’s not the default - who wants to lose whatever they’ve typed in when you tab away and tab back?