atom / atom-keymap

Atom's selector-based keymap system
MIT License
105 stars 57 forks source link

Uncaught TypeError: Cannot read property 'unmodified' of undefined (possible Mode_switch issue) #206

Closed itaniknight closed 7 years ago

itaniknight commented 7 years ago

Description

I used xmodmap to bind AltGr + ESDF to the arrow keys (so I don't have to actually reach the physical arrow keys all the time). This works in all applications, including Atom. In other applications, unbound Mode_switch combinations are ignored, but in Atom they cause an Uncaught TypeError.

So, for example:

To clarify, Atom does still print the expected characters, it just also causes a TypeError.

The xmodmap config file looks like this:

keycode 108 = Mode_switch

# note: I'm using the Dvorak keyboard layout.
# period, o, e, and u are in the same position as e, s, d, and f on a Qwerty keyboard.

keycode 26 = period greater Up
keycode 39 = o O Left
keycode 40 = e E Down
keycode 41 = u U Right

# q and k are where x and v are in Qwerty.

keycode 53 = q Q Home
keycode 55 = k K End

keycode 39 = o O Left means: type o with no modifiers, O when holding shift, and Left (the arrow key) when holding Mode_switch. Again, all of these keys work in Atom. It's the unbound combinations that cause the error. I'm reasonably confident Dvorak isn't causing this, as Atom has zero problems with it otherwise and Mode_switch isn't part of the layout by default.

System

Atom: 1.14.0-beta1 x64 Electron: 1.3.13 OS: Ubuntu 16.10 Thrown From: Atom Core

Stack Trace

Uncaught TypeError: Cannot read property 'unmodified' of undefined

At /usr/share/atom-beta/resources/app.asar/node_modules/atom-keymap/lib/helpers.js:39

TypeError: Cannot read property 'unmodified' of undefined
    at isLatinKeymap (/app.asar/node_modules/atom-keymap/lib/helpers.js:39:89)
    at exports.keystrokeForKeyboardEvent (/app.asar/node_modules/atom-keymap/lib/helpers.js:228:31)
    at KeymapManager.module.exports.KeymapManager.keystrokeForKeyboardEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:445:14)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:325:24)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/app.asar/src/window-event-handler.js:106:36)
    at /app.asar/src/window-event-handler.js:3:59)

Non-Core Packages

gruvbox 1.0.5 
language-lua 0.9.11 
language-renpy 1.6.0 
scrolloff 0.2.0 

Additional Information

I originally posted this in another issue, and @Ben3eeE requested I make a new one over here. I did my best to clarify the other questions in this new issue.

nathansobo commented 7 years ago

It sounds like our code to read the keyboard layout from the OS isn't returning a result for the key in question.

nathansobo commented 7 years ago

Hey. So I just introduced some null guards to cover cases where we don't have entries for the physical A, S, D, or F keys in the native map. It's basically going to assume your keyboard is latin which might be incorrect in some cases, but I think it's an improvement. You'll need to build 1.15.0 until the next major release to get these fixes. Thanks for the report!