This repository was archived by the owner on Apr 6, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ class VimState
3636 @ activateVisualMode (' characterwise' ) if @mode is ' command'
3737 , 100 )
3838
39+ @subscriptions .add atom .keymaps .onDidFailToMatchBinding (e) =>
40+ return unless e .keyboardEventTarget is @editorElement
41+ if @mode is ' operator-pending'
42+ atom .keymaps .cancelPendingState ()
43+ @ resetCommandMode ()
44+
3945 @editorElement .classList .add (" vim-mode" )
4046 @ setupCommandMode ()
4147 if settings .startInInsertMode ()
Original file line number Diff line number Diff line change @@ -418,3 +418,25 @@ describe "VimState", ->
418418 keydown (' `' )
419419 commandModeInputKeydown (' q' )
420420 expect (editor .getCursorScreenPosition ()).toEqual [1 , 2 ]
421+
422+ describe " unknown key bindings" , ->
423+ beforeEach ->
424+ editor .setText " line one\n line two\n "
425+ editor .setCursorBufferPosition [0 , 0 ]
426+
427+ it " cancels short pending operations on unrecognized keybinding" , ->
428+ keydown ' c'
429+ keydown ' q' # cq doesn't work, should cancel
430+ keydown ' w'
431+ expect (editor .getCursorBufferPosition ()).toEqual [0 , 5 ]
432+ expect (editor .getText ()).toBe " line one\n line two\n "
433+ expect (vimState .mode ).toEqual ' command'
434+
435+ it " cancels long pending operations on unrecognized keybinding" , ->
436+ keydown ' c'
437+ keydown ' i'
438+ keydown ' 3' # i3 is unrecognized, should cancel the whole `ci3` sequence
439+ keydown ' w'
440+ expect (editor .getCursorBufferPosition ()).toEqual [0 , 5 ]
441+ expect (editor .getText ()).toBe " line one\n line two\n "
442+ expect (vimState .mode ).toEqual ' command'
You can’t perform that action at this time.
0 commit comments