I would like the keybinds that open the sidebars on the left (eg file explorer, git, debug) to work like the keybind to open the terminal, ie:
If the sidebar I want (eg the git/scm one, when I press ctrl+shift+g
) isn't visible then it should be shown (this works out of the box)
If it is already visible, the sidebar should be hidden (by default the keybinds do nothing in this case)
Before I file a bug report, I'm wondering if it's possible to achieve this with "when" expressions in the keybinding panel.
All I'd need is a "when" expression that can detect if the given sidebar (explorer, scm, debug, etc.) is already visible.
I've gotten kinda close to my goal by having the keybinds check whether any sort of sidebar is visible:
{
"key": "ctrl+shift+g",
"command": "-workbench.view.scm"
},
{
"key": "ctrl+shift+g",
"command": "workbench.view.scm",
"when": "!sideBarVisible"
},
{
"key": "ctrl+shift+g",
"command": "workbench.action.closeSidebar",
"when": "sideBarVisible"
},
{
"key": "ctrl+shift+d",
"command": "-workbench.view.debug"
},
{
"key": "ctrl+shift+d",
"command": "workbench.view.debug",
"when": "!sideBarVisible"
},
{
"key": "ctrl+shift+d",
"command": "workbench.action.closeSidebar",
"when": "sideBarVisible"
},
{
"key": "ctrl+shift+e",
"command": "-workbench.view.explorer"
},
{
"key": "ctrl+shift+e",
"command": "workbench.view.explorer",
"when": "!sideBarVisible"
},
{
"key": "ctrl+shift+e",
"command": "workbench.action.closeSidebar",
"when": "sideBarVisible"
},
This works most of the time, but fails when there is a sidebar visible, but it's not the one I'm requesting. Example: If the file explorer sidebar is showing, and I press shift+ctrl+g
I want the sidebar to change to the scm view, but instead it hides the sidebar.
Is there a "when" expression that says what's in the sidebar? Or maybe a different "when" expression for detecting each of the specific sidebars (scm, explorer, debug, etc.)?
I found the "when" expression "scmRepository", which is sorta close, but that seems to detect whether the cursor is in the commit message input box, not whether the scm sidebar is visible.
Thanks!
question from:
https://stackoverflow.com/questions/65852291/vs-code-scm-explorer-debug-keybinds-to-hide-sidebar-if-already-selected