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

Command-/ with Dvorak keyboard on Mac OS X no longer comments/uncomments #1492

Closed
erichocean opened this issue Dec 19, 2015 · 24 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug keyboard-layout Keyboard layout issues macos Issues with VS Code on MAC/OS X verified Verification succeeded
Milestone

Comments

@erichocean
Copy link

Now it "outdents." There are a few other potentially related oddities, such as Command-[ causing the text to get smaller, and Command-] causing the text to get larger.

If I had to guess, someone change the key-mapping code to work off of key codes and not characters, so it think it's using a QWERTY keyboard, even though it's not.

This worked prior to the latest update (broken version is 0.10.5 dfc08dc).

@mathiasvr
Copy link
Contributor

I have this exact same problem! The keybindings.json tells me i have to use a different shortcut for my current keyboard layout (cmd+z) but that does not work (it still undo's). Changing my keyboard layout does not work either, the keybindings.json comes up with different but still wrong suggestions.

@egamma egamma added the bug Issue identified by VS Code Team member as probable bug label Dec 20, 2015
@egamma egamma added this to the Backlog milestone Dec 20, 2015
@alexdima
Copy link
Member

@erichocean @mathiasvr Sorry about that!

This might be caused by our code that work arounds Chromium's implementing a w3c section only on Mac: https://github.com/Microsoft/vscode/blob/39602b3adbb50945fd8fe70017a2ffbd3000a477/src/vs/workbench/services/keybinding/electron-browser/nativeKeymap.ts#L204

How can I try to reproduce on a qwerty keyboard? is there a dvorak kb layout setting on the mac (I'm not usually working on a mac)?

@mathiasvr
Copy link
Contributor

Yes i'm actually on a physical qwerty keyboard as well, in keyboard settings you can add dvorak as input source.

@alexdima alexdima added the macos Issues with VS Code on MAC/OS X label Jan 13, 2016
@alexdima alexdima modified the milestones: Jan 2016, Backlog Jan 26, 2016
@alexdima
Copy link
Member

@erichocean @mathiasvr There is indeed a difference between 0.10.4 and 0.10.5

The difference is that starting with 0.10.5 we have code in that reverts a questionable feature implemented by Chromium only on the mac -- B.2.4 Optionally fixed virtual key codes. This is in the w3c spec to support "legacy content expecting US-English keyboard layout", which is not the case with VS Code. We had to revert this feature because it caused keyboard input to be unreliable -- please see #1302 for an example on how this issue manifests itself.

I have checked on @isidorn mac that we do the right thing. i.e. when you open the default keybindings we inform that you must press cmd+z to get the comment line toggle.
screen shot 2016-01-28 at 17 37 45

Please read further about different keyboard layouts in the documentation
https://code.visualstudio.com/docs/customization/keybindings#_keyboard-layouts

Also, what would be needed to give a better user experience would be to be able to contribute keybindings based on keyboard layouts as asked in #1240

@bpasero bpasero assigned aeschli and unassigned alexdima Jan 29, 2016
@aeschli aeschli assigned weinand and unassigned aeschli Jan 29, 2016
@weinand weinand added the verified Verification succeeded label Jan 29, 2016
@erichocean
Copy link
Author

@alexandrudima The screenshot you posted is incorrect. Command-Z on the Mac is "Undo". Seriously, try it: it'll run the Undo command, not the editor.action.commentLine command as is implied by the pop-up.

That said, I was able to follow the other links and revive the main commands I was missing, in a custom keybinding.json file that looks like this:

[
{
  "key": "cmd+[",
  "command": "editor.action.commentLine",
  "when": "editorTextFocus"
},
{
  "key": "cmd+-",
  "command": "editor.action.outdentLines",
  "when": "editorTextFocus"
},
{
  "key": "cmd+=",
  "command": "editor.action.indentLines",
  "when": "editorTextFocus"
}
]

That's all I needed to get back to normal productivity in the editor. Thanks!

P.S. Since someone went through all the effort to figure out that the key commands are wrong and display the custom UI gizmo, why not just fix them? I mean, if I can do it manually…why not just do it automatically? The editor is basically broken right now without the manual fixes. You can still display the correct key-sequence in the UI (now that you've got the code to do that…).

@alexdima
Copy link
Member

alexdima commented Feb 1, 2016

@erichocean I will look again into this as soon as I get my hands on a mac.

@novemberborn
Copy link

It looks like VSCode tries to preserve the physical shortcut key. The toggle line comment shortcut is cmd+/. If you press the physical / key on a QWERTY keyboard that uses the Dvorak layout you get z. VSCode tries to map the shortcut to cmd+z, which doesn't even work since Undo binds higher.

This is why rebinding to cmd+[ works. On a physical QWERTY keyboard [ is mapped to /. By mapping the physical [ key I get the desired shortcut (cmd+/).

I don't think the shortcuts should reflect the physical keyboard. They should match the keyboard layout. I know what physical key to press to trigger a /. This is how Atom behaves.

@HookyQR
Copy link
Contributor

HookyQR commented Jul 9, 2016

{ "key": ".",                     "command": "^acceptSelectedSuggestion",
                                     "when": "editorTextFocus && suggestWidgetVisible && suggestionSupportsAcceptOnKey && editorLangId == 'typescript'" },

Suggests: For your current keyboard layout press v

Really? Someone thought that was a solution?

@alexdima alexdima modified the milestones: Backlog, Jan 2016 Aug 9, 2016
@chexee
Copy link

chexee commented Aug 15, 2016

I went through and remapped all keybindings to DVORAK suggestions. Here's my keybindings.json if anyone else wants to do this and not go through every frickin' line.

But agree with @HookyQR – this is a really piss poor solution for folks with alternative keyboards. If you can detect what the shortcut should be, just swap it :/

[
    { 
        "key": "cmd+/",              
        "command": "editor.action.outdentLines",                                
        "when": "editorTextFocus" 
    },
    { 
        "key": "cmd+.",              
        "command": "editor.action.quickFix",
        "when": "editorTextFocus" 
    },
    { 
        "key": "shift+cmd+/",           
        "command": "editor.fold",
        "when": "editorFocus" 
    },
    {
        "key": "cmd+k cmd+[",           
        "command": "editor.foldRecursively",
        "when": "editorFocus" 
    },
    { 
        "key": "cmd+k cmd+]",           
        "command": "editor.unFoldRecursively",
        "when": "editorFocus"
    },
    { 
        "key": "shift+cmd+]",           
        "command": "editor.unfold",
        "when": "editorFocus" 
    },
    {
        "key": "cmd+[",
        "command": "editor.action.commentLine",
        "when": "editorTextFocus"
    },
    {
        "key": "cmd+-",
        "command": "editor.action.outdentLines",
        "when": "editorTextFocus"
    },
    {
        "key": "cmd+=",
        "command": "editor.action.indentLines",
        "when": "editorTextFocus"
    },
    { 
        "key": "ctrl+[",                
        "command": "workbench.action.navigateBack" 
    },
    { 
        "key": "ctrl+shift+[",          
        "command": "workbench.action.navigateForward"
    },
    {
        "key": "cmd+w",                 
        "command": "workbench.action.openGlobalSettings"
    },
    { 
        "key": "cmd+]",                
        "command": "workbench.action.zoomIn" 
    },
    { 
        "key": "cmd+[",                 
        "command": "workbench.action.zoomOut" 
    },
    { 
        "key": "v",                     
        "command": "^acceptSelectedSuggestion",
        "when": "editorTextFocus && suggestWidgetVisible && suggestionSupportsAcceptOnKey && editorLangId == 'typescript'" 
    },

]

@throughnothing
Copy link

throughnothing commented Nov 10, 2016

@chexee thanks for this! I find this still to be incredibly confusing. I can't have my dvorak-layout cmd + w (physical cmd + ,) to map to openGlobalSettings, while also having dvorak-layout cmd + , (physical cmd + w) map to close window. There seems to be no way I can make this happen, meaning I'll have to rebind one or the other.

For some reason, VSCode detects that cmd+, "maps to cmd+w on your layout" (which I don't really want, but can deal with), but if I make a mapping for cmd+w, it does not detect that that should "map to cmd+, on your layout", so there seems to be no way to resolve this.

Update: for now, I've mapped shift+cmd+w to get to preferences.

@chexee
Copy link

chexee commented Nov 10, 2016

I actually gave up on mapping. The above still didn't cover everything and the experience for dvorak is just taking too much time to make right. I probably won't switch until this is handled better.

@nicot
Copy link

nicot commented Nov 10, 2016

Would using event.key be better? Does Monaco support any browsers that don't fully support it?

That might eliminate a fair amount of code in keyCodes.ts, and enable keybindings like BrowserBack.

@mhat
Copy link

mhat commented Nov 17, 2016

Is there anything I can to do push for getting a real fix? vscode is effectively unusable w/ Dvorak and other non-physical layouts. Patreon?

@Jessidhia
Copy link

This seems to work for me on a fresh Sierra + VS Code install. Could it be a conflict with pre-existing configuration in the settings folder?

Even the ⌘+, shortcut issue seems to be gone (it would open the settings, but first would close the current tab as if it was ⌘+w).

@HookyQR
Copy link
Contributor

HookyQR commented Nov 18, 2016

For those of you still having issues, you can drop the 'fix' by editing the app code as I've mentioned here: #15624 (comment)

I've put in a PR (#15687) to remove the re-mapping altogether, since it is effectively useless, we'll see how that goes.

@alexdima
Copy link
Member

I have validated that we now (i.e. after PR #22894 aka #17521 -- in today's upcoming Insiders build) appear to behave correctly for this keyboard layout

image


Analysis of default keybinding for editor.action.commentLine

  • editor.action.commentLine is bound by default to the key code binding cmd+/
  • / can be produced through one scan code: [BracketLeft] . i.e.
    image
  • therefore, the action is bound by default to: Cmd+[BracketLeft] i.e.
    image

I have validated that pressing Cmd+[BracketLeft] does indeed toggle line comment.


This makes me believe the fix in PR #22894 aka #17521 resolves this issue.

@Tsmith18256
Copy link

I have just tried the latest version of VS Code and the latest Insiders build and this isn't behaving as expected with the Dvorak - QWERTY layout.

Mac's built in Dvorak - QWERTY layout allows typing in DVORAK, but reverts to QWERTY when holding command so you don't have to reach all the way across the keyboard to do common actions like copy and save.

VS Code is undoing all of Mac's work and returning the keyboard shortcuts back to Dvorak.

@jdavidbakr
Copy link

@Tsmith18256 I don't believe that's the default action on a Mac, I use DVORAK and actually get quite annoyed with any apps that would switch back to QWERTY with the modifier keys (I don't use any apps regularly that do that)

@Tsmith18256
Copy link

Tsmith18256 commented Apr 25, 2017

@jdavidbakr Not DVORAK, "Dvorak - QWERTY." It's another layout that's only available on Mac and one of my favourite parts about Mac over Windows/Linux.

@chexee
Copy link

chexee commented Apr 25, 2017 via email

@Tsmith18256
Copy link

@chexee Yeah exactly, and the issue is that I have it enabled and VS Code is ignoring it. On every program on my computer I press the QWERTY versions of Ctrl-C for copy, Ctrl-Z for undo, etc.

In VS Code, I have to press the Dvorak versions, even though I enabled Dvorak - QWERTY, which means reaching way across the keyboard for really common actions.

@chexee
Copy link

chexee commented Apr 25, 2017 via email

@HookyQR
Copy link
Contributor

HookyQR commented Apr 25, 2017

Yep, would have been easier if they just did the breaking change like I suggested originally. Broke a bunch of other stuff anyway. Oh well. ¯_(ツ)_/¯

@alexdima
Copy link
Member

There exists a workaround for the "Dvorak - QWERTY" keyboard layout explained in #23964. i.e. "keyboard.dispatch": "keyCode"

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug keyboard-layout Keyboard layout issues macos Issues with VS Code on MAC/OS X verified Verification succeeded
Projects
None yet
Development

No branches or pull requests