Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

vscode settings - VS Code scm/explorer/debug keybinds to hide sidebar if already selected

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:

  1. 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)

  2. 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.7k users

...