Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New commands are not being added to VSpaceCode's which-key menu #78

Closed
macintacos opened this issue Aug 1, 2020 · 3 comments
Closed

Comments

@macintacos
Copy link
Contributor

Not sure if this is an issue with vscode-which-key, VSpaceCode, or just a misplaced character somewhere, but with no validation I'm finding it hard to figure out what's going on.

I've been adding a lot of keybindings to my settings to emulate more and more Spacemancs functionality. I have the following configuration in my settings.json right now:

"vspacecode.bindingOverrides": [
    {
      "bindings": [
        {
          "command": "multiCommand.copyRelativePathAndPrintIt",
          "key": "r",
          "name": "...relative path of current file (copies it too)",
          "type": "command"
        },
        {
          "command": "extension.relativePath",
          "key": "R",
          "name": "...relative path of other file in project",
          "type": "command"
        },
        {
          "command": "multiCommand.copyRelativePathAndSelectedLinesAndPrintIt",
          "key": "l",
          "name": "...relative path of current file AND selected line numbers (copies it too)",
          "type": "command"
        }
      ],
      "keys": ["i", "f"],
      "name": "Insert file...",
      "type": "bindings"
    },
    {
      "bindings": [
        {
          "command": "copyFilePath",
          "key": "y",
          "name": "...current file with absolute path",
          "type": "command"
        },
        {
          "command": "copy-relative-path-and-line-numbers.path-only",
          "key": "r",
          "name": "...current file with relative path",
          "type": "command"
        },
        {
          "command": "copy-relative-path-and-line-numbers.both",
          "key": "R",
          "name": "...current file with relative path and current line numbers",
          "type": "command"
        },
        {
          "command": "fileutils.copyFileName",
          "key": "n",
          "name": "...current file name with extension",
          "type": "command"
        }
      ],
      "keys": ["f", "y"],
      "name": "Copy...",
      "type": "bindings"
    },
    {
      "command": "git.checkout",
      "key": "g.B",
      "name": "Branch",
      "type": "command"
    },
    {
      "command": "outline.focus",
      "key": "f.O",
      "name": "Focus file outline view",
      "type": "command"
    },
    {
      "command": "workbench.action.closeUnmodifiedEditors",
      "keys": "b.D",
      "name": "Close unmodified editors",
      "type": "command"
    },
    {
      "command": "fileutils.removeFile",
      "keys": "f.D",
      "name": "Delete current file",
      "type": "command"
    },
    {
      "command": "fileutils.renameFile",
      "keys": "f.R",
      "name": "Rename file",
      "type": "command"
    },
    {
      "command": "workbench.action.output.toggleOutput",
      "keys": "e.o",
      "name": "Toggle output view",
      "type": "command"
    },
    {
      "bindings": [
        {
          "command": "bookmarks.toggle",
          "key": "m",
          "name": "Toggle bookmark",
          "type": "command"
        }
      ],
      "keys": "B",
      "name": "Bookmark Actions",
      "type": "bindings"
    },
    {
      "bindings": [
        {
          "command": "editor.action.commentLine",
          "key": "l",
          "name": "Comment/uncomment line(s)",
          "type": "command"
        },
        {
          "command": "code-runner.run",
          "key": "r",
          "name": "Run code in curent file",
          "type": "command"
        },
        {
          "command": "multiCommand.copyAndCommentLines",
          "key": "y",
          "name": "Copy selection and comment line",
          "type": "command"
        }
      ],
      "keys": "c",
      "name": "Comment Actions",
      "type": "bindings"
    },
    {
      "bindings": [
        {
          "command": "workbench.action.openGlobalSettings",
          "key": ",",
          "name": "Open global settings",
          "type": "command"
        },
        {
          "command": "workbench.action.selectIconTheme",
          "key": "i",
          "name": "Choose icon theme",
          "type": "command"
        },
        {
          "command": "workbench.action.openGlobalKeybindings",
          "key": "k",
          "name": "Open global keybindings",
          "type": "command"
        },
        {
          "command": "workbench.action.openGlobalKeybindingsFile",
          "key": "K",
          "name": "Open global keybindings JSON",
          "type": "command"
        },
        {
          "command": "workbench.action.configureLanguageBasedSettings",
          "key": "l",
          "name": "Open language settings",
          "type": "command"
        },
        {
          "command": "workbench.action.openSettings",
          "key": "n",
          "name": "Open User snippets",
          "type": "command"
        },
        {
          "command": "workbench.action.openSettingsJson",
          "key": "s",
          "name": "Open global settings JSON",
          "type": "command"
        },
        {
          "command": "workbench.action.selectTheme",
          "key": "t",
          "name": "Choose color theme",
          "type": "command"
        },
        {
          "command": "extension.updateSettings",
          "key": "u",
          "name": "Update/upload settings",
          "type": "command"
        },
        {
          "command": "workbench.action.openWorkspaceSettings",
          "key": "w",
          "name": "Open workspace settings",
          "type": "command"
        },
        {
          "command": "workbench.action.openWorkspaceSettingsFile",
          "key": "W",
          "name": "Open workspace settings JSON",
          "type": "command"
        }
      ],
      "keys": ",",
      "name": "Settings/Preferences",
      "type": "bindings"
    }
  ],

I'm continuing to add more. The JSON document itself is not throwing any errors, and most of the commands are showing up for me. However, the SPC g B keybinding that I added does show up (there are other examples, but that's the one where I first noticed that they weren't showing up in the menu). This error is showing up in my console:

console.ts:137 [Extension Host] TypeError: Cannot read property 'length' of undefined
    at /Users/juliant/.vscode/extensions/vspacecode.whichkey-0.7.4/dist/extension.js:1:2364
    at Array.forEach (<anonymous>)
    at Function.overrideItems (/Users/juliant/.vscode/extensions/vspacecode.whichkey-0.7.4/dist/extension.js:1:2261)
    at t.default.register (/Users/juliant/.vscode/extensions/vspacecode.whichkey-0.7.4/dist/extension.js:1:5613)
    at u (/Users/juliant/.vscode/extensions/vspacecode.whichkey-0.7.4/dist/extension.js:1:3574)
    at _executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:631:163)
    at _doExecuteCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:630:348)
    at _.executeCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:630:254)
    at Object.executeCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:911:820)
    at /Users/juliant/.vscode/extensions/vspacecode.vspacecode-0.7.3/dist/extension.js:1:6336
    at t.activate (/Users/juliant/.vscode/extensions/vspacecode.vspacecode-0.7.3/dist/extension.js:1:6443)
    at Function._callActivateOptional (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:837:509)
    at Function._callActivate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:837:160)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:835:703
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async Promise.all (index 3)
    at async Promise.all (index 0)

It says it's which-key that's hitting the error, but I can't tell if it's VSpaceCode that is interpreting my settings incorrectly (which is thus being passed to which-key). Happy to move this issue over to that repo if this is an issue with which-key itself.

Please let me know if there's anything that I can do to help you get to the bottom of this. I'm going to continue to fiddle around with my settings to see if I can figure it out.

@macintacos
Copy link
Contributor Author

I narrowed it down to these two being the only commands that are not showing up in the which-key menu:

    {
      "type": "command",
      "name": "Branch",
      "key": "g.B",
      "command": "git.checkout"
    },
    {
      "type": "command",
      "name": "Focus file outline view",
      "key": "f.O",
      "command": "outline.focus"
    },

I can't figure out why there'd be anything wrong with them though. When I removed those two, the error in the console went away.

@macintacos
Copy link
Contributor Author

Oh my goodness. It's "keys" not "key". Added the "s" at the end and it worked.

🤦

Closing this out. Not sure if there's much you can do about validation inthe settings.json file, but I'll go ahead and just blame this on PEBKAC.

@stevenguh
Copy link
Member

stevenguh commented Aug 1, 2020

I am glad you figured it out, and sorry for the late reply. I think there are rooms for better JSON validation and better documentation. Opened an issue VSpaceCode/vscode-which-key#7 to track it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants