-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Keybinding remapping applied beyond specified scope ("when":) #83412
Comments
editorTextFocus issue? |
@Tyriar As @tecosaur mentioned here, the issue does not reproduce on Linux, suggesting that it's a Mac problem. The first possibility that came to mind was that |
@janosh with just plain vscode, have you tried adding something like {
"key": "cmd+v",
"command": "editor.action.addCommentLine",
"when": "editorTextFocus"
} to your |
@tecosaur Good call! That works as expected. So not a problem with Still, even in an empty project (i.e. no config) and with all other extension disabled, as soon as I enable LaTeX Utilities, I can no longer shortcut paste (right click to paste still works) in the integrated terminal or in search inputs. With only LaTeX Workshop enabled, the problem is gone. So maybe it's LU after all? |
To me this just seems odd. As long as that Could you try removing that keybinding statement from the
|
In "keybindings": [
// {
// "key": "ctrl+shift+v",
// "mac": "cmd+shift+v",
// "command": "latex-utilities.formattedPaste",
// "when": "!config.latex-utilities.formattedPaste.useAsDefault && editorTextFocus && editorLangId == 'latex'"
// },
// {
// "key": "ctrl+shift+v",
// "mac": "cmd+shift+v",
// "command": "editor.action.clipboardPasteAction",
// "when": "config.latex-utilities.formattedPaste.useAsDefault && editorTextFocus && editorLangId == 'latex'"
// },
// {
// "key": "ctrl+v",
// "mac": "cmd+v",
// "command": "latex-utilities.formattedPaste",
// "when": "config.latex-utilities.formattedPaste.useAsDefault && editorTextFocus && editorLangId == 'latex'"
// }
], and that solved the issue. After reloading VS Code, cmd + v worked again everywhere even with LU enabled. One thing I should have mentioned earlier (but forgot) is that with LU enabled, the context menu shows that pasting is remapped to cmd + shift + v (that was before commenting out the |
In that case, I return to suspecting vscode. Based on what you said about the context menu saying that remapping has occurred, perhaps the keybindings parser identifies the remapping and applies it globally (i.e. ignoring the when). That's just speculation though, I'll leave the detailed diagnosis to those working on vscode who have to fix it. |
Oh @janosh, a separate MWE to try, how about just adding this to your user keybindings (and no LU etc.) {
"key": "cmd+shift+v",
"command": "editor.action.clipboardPasteAction",
"when": "editorTextFocus"
},
{
"key": "cmd+v",
"command": "editor.action.addCommentLine",
"when": "editorTextFocus"
} |
Both keybindings work as expected in the editor and, more importantly, the remapped // {
// "key": "cmd+shift+v",
// "command": "editor.action.clipboardPasteAction",
// "when": "editorTextFocus"
// },
{
"key": "cmd+v",
"command": "editor.action.addCommentLine",
"when": "editorTextFocus"
} pasting in terminal and search is back to cmd + v. |
Fantastic! I think we've narrowed down on the issue at hand. Keybinding remapping is applied beyond the specified scope ( I'd consider updating the title and MWE on your initial comment at this point. |
Nice analysis! The root cause is:
This makes our reverse lookup for But the unreasonable thing is how Paste actually works on macs in other inputs than the editor. Basically, I have encountered this before and I thought it is so rare that it doesn't warrant further workarounds from us... See #74599 (comment) But now I think we should perhaps add some workaround specifically for this case... Perhaps we should always consider The minimal repro would be in
|
@alexandrudima from what you've said, I understand that vscode captures the shortcut, and then tries the highest priority keybinding. Correct? Would a decent approach be tweaking the behaviour such that if the |
Normally, if you look at our keybindings.json we don't have any keybindings for paste outside of a code editor. Search for On Windows and on Linux, our lack of a keybinding results by default in Electron generating a On top of this, the mac has a weird twist. When we render a keybinding in the top level menu, this is not only rendering it... The OS dispatches keybindings to the menu directly... In fact, we don't even get the keybinding anymore... You can notice this by seeing a blue flash in the menu... If we render anything in the menus, pressing that key combination will result in Electron/the OS interpreting and capturing that and converting that into a menu invocation... So when we render Anyways, the mac menu is weird, the default That should result in things working even when |
Huh. This all sounds like a huge hassle/mess. After reading that I'm quite happy just dealing with my nice little extension without having to deal with that headache 😃 Anyway, thanks for looking at this, and best of luck! |
Steps to Reproduce:
Presumably due to the shortcut
The text was updated successfully, but these errors were encountered: