VSpaceCode / vscode-which-key

which-key like menu for Visual Studio Code
https://vspacecode.github.io/docs/whichkey
MIT License
179 stars 18 forks source link

Not very responsive #20

Closed shadyalfred closed 4 years ago

shadyalfred commented 4 years ago

Bug description

I don't know if it's the same responsive speed on all machines or just on mine, but on my device it takes a second or so till the menu appears. And I checked the delay setting, it was 0. I even tried to set it to 1, but nothing changes. The speed of the menu showing up isn't really the issue, the problem is that I can't use the bindings, I have to wait till the menu shows up otherwise it executes other vim commands, or whatever the key I pressed is bound to, or hangs on a different menu because the extension couldn't catch up with my keystrokes.

To Reproduce

Try to chain multiple nested bindings quickly, i.e. (VSpaceCode) Space f p

Expected behavior

Executes the binding pressed.

System information

image

stevenguh commented 4 years ago

Related: https://github.com/VSpaceCode/VSpaceCode/issues/127#issuecomment-711362712

We are relying on the input element provided by the QuickPick menu to intercept input, so you do have to wait for the menu. However, setting the delay value like 500 (in ms) might help to not render all the menu items (it only renders the input element box during the delay period).

My question is why would the menu triggering be that slow? If you have experience with developer console. Maybe you can help us by profiling.

Also we might able to see if there something out of place by posting your settings.json and keybindings.json.

shadyalfred commented 4 years ago

Here's a gif of the triggering speed, the cyan rectangle at the bottom shows my keystrokes. which key lag


I'm not sure how profiling is done, but this might help

cpuprofile.zip


Click to toggle contents of `settings.json`

```json { "telemetry.enableTelemetry": false, "telemetry.enableCrashReporter": false, "terminal.integrated.shell.windows": "C:\\Program Files\\PowerShell\\6\\pwsh.exe", "terminal.integrated.shellArgs.windows": [ "--nologo" ], "terminal.external.windowsExec": "wt", "update.mode": "start", "workbench.iconTheme": "eq-material-theme-icons-darker", "editor.fontFamily": "Hasklig, 'Courier New', monospace", "editor.fontLigatures": true, "editor.fontSize": 16, "editor.lineHeight": 35, "editor.foldingStrategy": "auto", "editor.showFoldingControls": "always", "editor.quickSuggestionsDelay": 100, "editor.minimap.enabled": false, "editor.cursorBlinking": "solid", "editor.suggestFontSize": 14, "editor.suggestLineHeight": 30, "vsicons.dontShowNewVersionMessage": true, "php.validate.executablePath": "C:\\xampp\\php\\php.exe", "php.suggest.basic": false, "intelephense.maxMemory": 256, "intelephense.telemetry.enabled": false, "intelephense.diagnostics.undefinedTypes": false, "workbench.startupEditor": "newUntitledFile", "npm-intellisense.scanDevDependencies": true, "htmlhint.documentSelector": [ "html", "php" ], "htmlhint.options": { "spec-char-escape": false, "tag-pair": true, "id-unique": true, "attr-no-duplication": true, }, "editor.renameOnType": true, "gitlens.hovers.currentLine.over": "line", "gitlens.codeLens.enabled": false, "gitlens.codeLens.authors.enabled": false, "gitlens.codeLens.recentChange.enabled": false, "gitlens.currentLine.enabled": false, "gitlens.hovers.annotations.changes": false, "gitlens.hovers.annotations.details": false, "gitlens.hovers.annotations.enabled": false, "gitlens.hovers.avatars": false, "gitlens.hovers.currentLine.changes": false, "gitlens.hovers.currentLine.details": false, "gitlens.hovers.currentLine.enabled": false, "workbench.colorTheme": "Material Theme Darker", "workbench.colorCustomizations": { "activityBarBadge.background": "#00BCD4", "activityBar.activeBorder": "#00BCD4", "list.activeSelectionForeground": "#00BCD4", "list.inactiveSelectionForeground": "#00BCD4", "list.highlightForeground": "#00BCD4", "scrollbarSlider.activeBackground": "#00BCD450", "editorSuggestWidget.highlightForeground": "#00BCD4", "textLink.foreground": "#00BCD4", "progressBar.background": "#00BCD4", "pickerGroup.foreground": "#00BCD4", "tab.activeBorder": "#00BCD4", "notificationLink.foreground": "#00BCD4", "editorWidget.resizeBorder": "#00BCD4", "editorWidget.border": "#00BCD4", "settings.modifiedItemIndicator": "#00BCD4", "settings.headerForeground": "#00BCD4", "panelTitle.activeBorder": "#00BCD4", "breadcrumb.activeSelectionForeground": "#00BCD4", "menu.selectionForeground": "#00BCD4", "menubar.selectionForeground": "#00BCD4", "editor.findMatchBorder": "#00BCD4", "selection.background": "#00BCD440", "statusBarItem.remoteBackground": "#00BCD4" }, "materialTheme.accent": "Cyan", "editor.wordWrap": "on", "vim.easymotionMarkerBackgroundColor": "#FFFFFF", "haskell.enable": false, "vim.easymotion": true, "vim.useSystemClipboard": true, "vim.replaceWithRegister": true, "vim.sneak": true, "vim.incsearch": true, "vim.hlsearch": true, "vim.foldfix": true, "vim.highlightedyank.enable": true, "vim.normalModeKeyBindingsNonRecursive": [ { "before": [ "", "%" ], "commands": [ "editor.emmet.action.matchTag" ] }, { "before": [ "g", "s", "f" ], "after": [ "leader", "leader", "s" ] }, { "before": [ "g", "s", "l" ], "after": [ "leader", "leader", "leader", "b", "d", "j", "k" ] }, { "before": [ "g", "s", "j" ], "after": [ "leader", "leader", "j" ] }, { "before": [ "g", "s", "k" ], "after": [ "leader", "leader", "k" ] }, { "before": [ "g", "s", "w" ], "after": [ "leader", "leader", "leader", "b", "d", "w" ] }, { "before": [ "g", "t" ], "after": [], "commands": [ { "command": "workbench.action.nextEditor", "args": [] } ] }, { "before": [ "g", "T" ], "after": [], "commands": [ { "command": "workbench.action.previousEditor", "args": [] } ] }, { "before": [ "]", "b" ], "after": [], "commands": [ { "command": "workbench.action.nextEditor", "args": [] } ] }, { "before": [ "[", "b" ], "after": [], "commands": [ { "command": "workbench.action.previousEditor", "args": [] } ] }, { "before": [ "]", "e" ], "after": [], "commands": [ { "command": "editor.action.marker.next", "args": [] } ] }, { "before": [ "[", "e" ], "after": [], "commands": [ { "command": "editor.action.marker.prev", "args": [] } ] }, { "before": [ "" ], "commands": [ "vspacecode.space" ] } ], "vim.visualModeKeyBindingsNonRecursive": [ { "before": [ "" ], "commands": [ "doom-code.space" ] }, { "before": [ ">" ], "commands": [ "editor.action.indentLines" ] }, { "before": [ "<" ], "commands": [ "editor.action.outdentLines" ] }, { "before": [ "", "%" ], "commands": [ "editor.emmet.action.matchTag" ] }, { "before": [ "", "" ], "after": [], "commands": [ { "command": "workbench.action.quickOpen", "args": [] } ] }, { "before": [ "", ":" ], "after": [], "commands": [ { "command": "workbench.action.showCommands", "args": [] } ] }, { "before": [ "f", "d" ], "after": [ "" ] }, { "before": [ "", "j", "=" ], "after": [], "commands": [ { "command": "editor.action.format", "args": [] } ] }, { "before": [ "g", "s", "f" ], "after": [ "leader", "leader", "s" ] }, { "before": [ "g", "s", "l" ], "after": [ "leader", "leader", "leader", "b", "d", "j", "k" ] }, { "before": [ "g", "s", "j" ], "after": [ "leader", "leader", "j" ] }, { "before": [ "g", "s", "k" ], "after": [ "leader", "leader", "k" ] }, { "before": [ "g", "s", "w" ], "after": [ "leader", "leader", "leader", "b", "d", "w" ] }, { "before": [ "g", "t" ], "after": [], "commands": [ { "command": "workbench.action.nextEditor", "args": [] } ] }, { "before": [ "g", "T" ], "after": [], "commands": [ { "command": "workbench.action.previousEditor", "args": [] } ] }, { "before": [ "]", "b" ], "after": [], "commands": [ { "command": "workbench.action.nextEditor", "args": [] } ] }, { "before": [ "[", "b" ], "after": [], "commands": [ { "command": "workbench.action.previousEditor", "args": [] } ] }, { "before": [ "]", "e" ], "after": [], "commands": [ { "command": "editor.action.marker.next", "args": [] } ] }, { "before": [ "[", "e" ], "after": [], "commands": [ { "command": "editor.action.marker.prev", "args": [] } ] }, { "before": [ "" ], "commands": [ "vspacecode.space" ] } ], "workbench.editor.enablePreview": false, "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "diffEditor.ignoreTrimWhitespace": false, "vim.visualstar": true, "vspacecode.bindingOverrides": [ { "keys": " ", "name": "Find file in project", "type": "command", "command":"workbench.action.quickOpen", }, { "keys": ":", "name": "Commands...", "type": "command", "command":"workbench.action.showCommands", } ], } ```


Click to toggle contents of `keybindings.json`

```json [ { "key": "tab", "command": "extension.vim_tab", "when": "editorFocus && vim.active && !inDebugRepl && vim.mode != 'Insert' && editorLangId != 'magit'" }, { "key": "tab", "command": "-extension.vim_tab", "when": "editorFocus && vim.active && !inDebugRepl && vim.mode != 'Insert'" }, { "key": "x", "command": "magit.discard-at-point", "when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/" }, { "key": "k", "command": "-magit.discard-at-point" }, { "key": "-", "command": "magit.reverse-at-point", "when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/" }, { "key": "v", "command": "-magit.reverse-at-point" }, { "key": "shift+-", "command": "magit.reverting", "when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/" }, { "key": "shift+v", "command": "-magit.reverting" }, { "key": "shift+o", "command": "magit.resetting", "when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/" }, { "key": "shift+x", "command": "-magit.resetting" }, { "key": "x", "command": "-magit.reset-mixed" }, { "key": "ctrl+u x", "command": "-magit.reset-hard" }, { "key": "y", "command": "-magit.show-refs" }, { "key": "ctrl+j", "command": "workbench.action.quickOpenSelectNext", "when": "inQuickOpen" }, { "key": "ctrl+k", "command": "workbench.action.quickOpenSelectPrevious", "when": "inQuickOpen" }, { "key": "ctrl+j", "command": "selectNextSuggestion", "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus" }, { "key": "ctrl+k", "command": "selectPrevSuggestion", "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus" }, { "key": "ctrl+j", "command": "showNextParameterHint", "when": "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible" }, { "key": "ctrl+k", "command": "showPrevParameterHint", "when": "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible" }, { "key": "ctrl+h", "command": "file-browser.stepOut", "when": "inFileBrowser" }, { "key": "ctrl+l", "command": "file-browser.stepIn", "when": "inFileBrowser" }, { "key": "space", "command": "vspacecode.space", "when": "activeEditorGroupEmpty && focusedView == '' && !whichkeyActive" }, { "key": "y", "command": "vspacecode.showMagitRefMenu", "when": "editorTextFocus && editorLangId == 'magit' && vim.mode == 'Normal'" }, { "key": "ctrl+l", "command": "acceptSelectedSuggestion", "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus" } ] ```

MarcoIeni commented 4 years ago

I saw that you have several things bound to space in your settings.json. For example:

{
            "before": [
                "<space>"
            ],
            "commands": [
                "doom-code.space"
            ]
        },

Can you try to remove everything except what's required by VSpaceCode? Maybe you have something that is conflict.

stevenguh commented 4 years ago

In addition to Marco's findings, the follow binding In your vim.normalModeKeyBindingsNonRecursive probably cause the slowness, because vim is looking for additional input "%"

        {
            "before": [
                "<space>",
                "%"
            ],
            "commands": [
                "editor.emmet.action.matchTag"
            ]
        }

Try removing those bindings. For this one I am listing specifically, you can remove it and use the overrides to add it to menu instead of using vim's binding. See https://vspacecode.github.io/docs/menu-customization#addreplace

shadyalfred commented 4 years ago
       {
            "before": [
                "<space>",
                "%"
            ],
            "commands": [
                "editor.emmet.action.matchTag"
            ]
        }

This what was causing the latency, thanks!