microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.96k stars 28.77k forks source link

TCIM.Zhuyin Keyboard layout: Funny keybindings for letter based combinations (copy, paste, undo, etc.) #28237

Closed kit1858644 closed 7 years ago

kit1858644 commented 7 years ago

Steps to Reproduce:

I'm start using vs code, but I find the copy, paste shortcut in vscode is crazy.

Normally the copy shortcut is cmd+c, but in my vscode the shortcut is Control+alt+cmd+C

please help!!

shortcut photo Screen Shot_zpsvuhyux64.png

jens1o commented 7 years ago

You can change that keybinding.

kit1858644 commented 7 years ago

I trird, but it don't work.

sandy081 commented 7 years ago

@kit1858644 By any chance you have customised these keybindings? Can you please open Keyboard Shortcuts and see the keybindings for above actions? Check if they are Default or User defined

image

kit1858644 commented 7 years ago

@sandy081 It doesn't have User setting, but it have two default setting, how can I delete the second one default setting?

Thanks your help.

Keybuild photo Screen Shot 2017-06-09 at 10.24.41 PM_zpsduwsmi61.png

sandy081 commented 7 years ago

@kit1858644 Thats very strange.. Can you open keybindings.json file, you can see the link just below the search box. Please provide us the Default keybindings (content in the left side editor).

Thanks

hungys commented 7 years ago

This may be related: #28046

I also had control+option+command+c/v when command+c/v not working.

cc @bpasero @alexandrudima

alexdima commented 7 years ago

@kit1858644 Can you please tell us the list of extensions you have installed. One of the extensions you have installed is binding ctrl+alt+cmd+C to copy. Since we allow extensions to override built-in keybindings, the ctrl+alt+cmd+C keybinding is given preference and displayed in the Edit menu.

hungys commented 7 years ago

@alexandrudima

If an extension binds a new keyboard shortcuts for copy, can we ALWAYS see this in contributions section of the extension? If so, going through all the contributions may be helpful for judging if any extension is the root cause.

Like Sublime Text Keymap,

alexdima commented 7 years ago

@hungys Yes, the Sublime Text Keymap is in no way special. Any extension can contribute keybindings and any extension that does so will show the keybindings it contributes under the "Contributions" section.

hungys commented 7 years ago

@alexandrudima

Thanks, that makes sense. And I have confirmed that all my installed extensions don't have keybindings for copy/paste :)

alexdima commented 7 years ago

@hungys Now that I think more about it, this might also be caused by our mapping of default keybindings based on keyboard layouts. This might also depend on what keyboard layout you have activated and what OSX returns in the TISCopyCurrentKeyboardInputSource call we do. Which keyboard layouts do you regularly use?

When the issue occurs, could you open an editor and run F1 > Developer: Inspect Key Mappings.

hungys commented 7 years ago

@alexandrudima

I'll try it next time. (Actually it didn't occur during these two days...)

alexdima commented 7 years ago

I will close this issue for now since this might be caused by a specific keyboard layout, which we don't know.

@hungys @kit1858644 if you find out what keyboard layout caused this, please let us know and attach the output of Inspect Key Mappings.

hungys commented 7 years ago

@alexandrudima

Luckily... the issue finally occurred again when you closed this LOL

Here are the dumped key mappings: https://www.pastiebin.com/595386b05d09f

Layout info:
{
    "id": "com.apple.keylayout.US",
    "lang": "en"
}
isUSStandard: true

Also I found that after I opened the Keyboard Shortcuts editor and checked the keybindings.json (it was actually empty), the keybindings just went normal again (without restarting VS Code)...

FYI, I'm running on the latest Insiders build.

alexdima commented 7 years ago

@hungys

Do you have other keyboard layouts installed on your system besides the native US keyboard layout? Do you constantly switch between those keyboard layouts? (even when focused outside of VS Code?)

On OSX we react to keyboard layout changes and adjust our keybindings based on the current keyboard layout.

I am thinking you have a keyboard layout that produces c when pressing C and also when pressing AltGr+C; z when pressing Z and also when pressing AltGr+Z, which leads us to "double up" all our keybindings from cmd+c to also cmd+ctrl+alt+c, etc.

It looks like you captured the key mappings while you were on the US standard keyboard layout and not while you were on the "other one", which causes this issue.

hungys commented 7 years ago

@alexandrudima

I think I have two input methods on my macOS. Here is another keyboard layout detected by VS Code. I used this IME for typing Chinese. (mostly outside of VS Code)

http://dpaste.com/11F1363

Layout info:
{
    "id": "com.apple.inputmethod.TCIM.Zhuyin",
    "lang": "zh-Hant"
}
isUSStandard: false

I am thinking you have a keyboard layout that produces c when pressing C and also when pressing AltGr+C; z when pressing Z and also when pressing AltGr+Z, which leads us to "double up" all our keybindings from cmd+c to also cmd+ctrl+alt+c, etc.

I'm not sure if this really happened with Chinese IME?

alexdima commented 7 years ago

@hungys Yes, that's it! Thanks for getting back to me:

e.g.

    "KeyC": {
        "value": "ㄏ",
        "valueIsDeadKey": false,
        "withShift": "C",
        "withShiftIsDeadKey": false,
        "withAltGr": "c",
        "withAltGrIsDeadKey": false,
        "withShiftAltGr": "C",
        "withShiftAltGrIsDeadKey": false
    }

Our default keybinding for copy is cmd+c. We then look at this information and see that on this keyboard layout c is producible via AltGr+[KeyC] (ctrl+alt+[KeyC]). We then proceed to "translate" the default keybinding cmd+c to cmd+ctrl+alt+[KeyC].

hungys commented 7 years ago

@alexandrudima

Finally... hope the fix works! 💯

By the way, TCIM.Zhuyin may not be the only case. There is also something like TCIM.Pinyin, and I believe OP was using input methods under SCIM. (TC for Traditional Chinese; SC for Simplified Chinese)

alexdima commented 7 years ago

@hungys Yes, tomorrow's Insiders should contain the fix and keyboard.dispatch: "keyCode" should not be needed anymore.

The fix is not specific to a single keyboard layout, it targets all keyboard layouts where latin letters are not produced without modifiers, and with the information I got from you (thanks again), I could write a test to ensure we don't regress.