How can I let vscode know when SCM visible or not?

风流意气都作罢 提交于 2021-01-29 04:46:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!