In vim command-mode, only eat insertion keys, not other modifiers

This commit is contained in:
Nathan Sobo
2012-01-13 14:23:58 -08:00
parent a7e8246de0
commit b4886bb6d6
2 changed files with 9 additions and 3 deletions

View File

@@ -14,12 +14,18 @@ describe "VimMode", ->
expect(editor).toHaveClass 'command-mode'
describe "command-mode", ->
it "stops propagation on key events that don't have bindings so that they don't get inserted", ->
it "stops propagation on key events would otherwise insert a character, but allows unhandled non-insertions through", ->
event = keydownEvent('\\')
spyOn(event, 'stopPropagation')
editor.trigger event
expect(event.stopPropagation).toHaveBeenCalled()
event = keydownEvent('s', metaKey: true)
spyOn(event, 'stopPropagation')
editor.trigger event
expect(event.stopPropagation).not.toHaveBeenCalled()
describe "the i keybinding", ->
it "puts the editor into insert mode", ->
expect(editor).not.toHaveClass 'insert-mode'

View File

@@ -18,9 +18,9 @@ class VimMode
setupCommandMode: ->
atom.bindKeys '.command-mode', (e) ->
if e.keystroke.match /\d/
if e.keystroke.match /^\d$/
return 'command-mode:numeric-prefix'
if e.keystroke.match /./
if e.keystroke.match /^.$/
return false
@bindCommandModeKeys