How to debug keybinds in Visual Studio Code

北慕城南 提交于 2021-02-10 03:57:35

问题


I am trying to get the keybind for adding new cursors to work in Visual Studio Code (Ctrl+Alt+DownArrow / UpArrow). Currently pressing this combination of keys has no obvious effect, but is listed in my command palette as creating new cursors (and selecting the option from the command palette works as expected).

Therefore I am wondering if there is an easy way to work out why it isn't working, for example an output of what key combinations the editor receives and what commands it carries out on receiving a key combination?

Here is the command I am referring to (note that selecting it from palette works as shown),


回答1:


You can troubleshoot keybindings by opening the Command Palette and selecting Developer: Toggle Keyboard Shortcuts Troubleshooting

You can read more in the VS Code documentation,

To troubleshoot keybindings problems, you can execute the command Developer: Toggle Keyboard Shortcuts Troubleshooting. This will activate logging of dispatched keyboard shortcuts and will open an output panel with the corresponding log file.

You can then press your desired keybinding and check what keyboard shortcut VS Code detects and what command is invoked.




回答2:


I fixed my original issue by bringing up the dev tools in VSCode (Help > Toggle Developer Tools) and noticing the warning:

"Ctrl+Alt+ keybindings should not be used by default under Windows."

This was being thrown by a package unrelated to multi-cursor but highlighted the issue. It simply seems that you cannot use keybinds of that type under Windows, though I could not find any documentation on reserved Windows keybindings.

For debugging keybinds I ended up pulling down the vscode source and there is a promising looking interface IKeybindingService. I imagine a break-point in the lookupKeybindings function on a class implementing this interface would be useful for debugging keybinds, but having fixed my original issue I am not looking any further into this.



来源:https://stackoverflow.com/questions/46140269/how-to-debug-keybinds-in-visual-studio-code

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