问题
I would like to make toggle key with VScode's keybinding. with alt + 1 to 5 to toggle explorer and search, scm, debug extension
I could find "explorerViewletVisible" or "searchViewletVisible" But I couldn't find visibilities of scm (source control) and debug, extensions. I use "sideBarVisible" for these key but it is not a perfect solution. Does Anyone know right 'when expression' of these situations?
{
"key": "alt+1",
"command": "workbench.view.explorer",
},
{
"key": "alt+1",
"command": "workbench.action.toggleSidebarVisibility",
"when": "explorerViewletVisible"
},
{
"key": "alt+2",
"command": "workbench.view.search",
},
{
"key": "alt+2",
"command": "workbench.action.toggleSidebarVisibility",
"when": "searchViewletVisible"
},
{
"key": "alt+3",
"command": "workbench.view.scm",
},
{
"key": "alt+3",
"command": "workbench.action.toggleSidebarVisibility",
"when": "sideBarVisible"
},
回答1:
I found the way my self.. use "when": "sideBarFocus && activeViewlet == 'workbench.view.explorer'"
回答2:
But I couldn't find visibilities of scm (source control) and debug, extensions.
IF you want to require that the sideBar be focused as well as those views be opened.
"when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
"when": "sideBarFocus && activeViewlet == 'workbench.view.debug'"
"when": "sideBarFocus && activeViewlet == 'workbench.view.extensions'"
If you only want to ensure that those views be opened (and some other focus, like an editor is allowed), just remove the sideBarFocus
part:
"when": "activeViewlet == 'workbench.view.scm'"
"when": "activeViewlet == 'workbench.view.debug'"
"when": "activeViewlet == 'workbench.view.extensions'"
来源:https://stackoverflow.com/questions/56032425/how-can-i-let-vscode-know-when-scm-visible-or-not