VSpaceCode / VSpaceCode

Spacemacs like keybindings for Visual Studio Code

Home Page:https://vspacecode.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why does this `conditional` binding not work?

macintacos opened this issue · comments

Bug description

I'm getting a "No condition matched" error with the following, when my cursor is in an editor (and the sidebar is not focused):

"vspacecode.bindingOverrides": [
...
    {
      "icon": "eye",
      "keys": "l.f",
      "name": "Focus Primary Sidebar",
      "type": "conditional",
      "bindings": [
        {
          "key": "when:!sideBarFocus",
          "name": "Focus Primary Sidebar",
          "type": "command",
          "command": "workbench.action.focusSideBar"
        },
        {
          "key": "when:sideBarFocus",
          "name": "Close Primary Sidebar",
          "type": "command",
          "command": "workbench.action.closeSidebar"
        }
      ]
    },
...
]

Any ideas what I'm doing wrong here? I want to make the binding focus the sidebar when it's not focused, and then if invoked when the sidebar is focused, close the sidebar. From the example in the documentation, I think that this should work, but perhaps I'm just missing something.

Keybindings & Settings

My keybindings.json and settings.json files are too large to copy/paste here. Please let me know if you still need them in order to debug this.

System information

CleanShot 2023-05-30 at 16 42 29@2x

Oh I seem to have gotten the first half by adding this keybinding (after referencing this section of the docs):

  {
    "key": "l",
    "command": "whichkey.triggerKey",
    "args": {
      "key": "l",
      "when": "!sideBarFocus"
    },
    "when": "whichkeyVisible && !sideBarFocus"
  },

But I can't seem to get the second half of the condition to work - if the sidebar as focus, close the sidebar (with the same l.f binding). Will post here if I figure that out.

The possible issue is that when the which key is visible, the sideBarFocus is unset by vscode. That is usually the culprit when using this workaround. You will have to find other context variable to use.