Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.

Commit 798b8e1

Browse files
committed
actually apply this also outside operator-pending mode
e.g. in visual mode for `vix`
1 parent 4955d5f commit 798b8e1

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

lib/vim-state.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class VimState
3838

3939
@subscriptions.add atom.keymaps.onDidFailToMatchBinding (e) =>
4040
return unless e.keyboardEventTarget is @editorElement
41+
atom.keymaps.cancelPendingState()
4142
if @mode is 'operator-pending'
42-
atom.keymaps.cancelPendingState()
4343
@resetCommandMode()
4444

4545
@editorElement.classList.add("vim-mode")

spec/vim-state-spec.coffee

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -424,19 +424,33 @@ describe "VimState", ->
424424
editor.setText "line one\n line two\n"
425425
editor.setCursorBufferPosition [0, 0]
426426

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'
427+
describe "in operator-pending mode", ->
428+
beforeEach ->
429+
keydown 'c'
430+
431+
it "cancels short pending operations on unrecognized keybinding", ->
432+
keydown 'q' #cq doesn't work, should cancel
433+
keydown 'w'
434+
expect(editor.getCursorBufferPosition()).toEqual [0, 5]
435+
expect(editor.getText()).toBe "line one\n line two\n"
436+
expect(vimState.mode).toEqual 'command'
437+
438+
it "cancels long pending operations on unrecognized keybinding", ->
439+
keydown 'i'
440+
keydown '3' #i3 is unrecognized, should cancel the whole `ci3` sequence
441+
keydown 'w'
442+
expect(editor.getCursorBufferPosition()).toEqual [0, 5]
443+
expect(editor.getText()).toBe "line one\n line two\n"
444+
expect(vimState.mode).toEqual 'command'
445+
446+
describe "in visual mode", ->
447+
beforeEach ->
448+
keydown 'v'
449+
450+
it "cancels whole unrecognized keybinding", ->
451+
keydown 'i'
452+
keydown '3' #i3 is unrecognized, should cancel the whole `i3` sequence
453+
keydown 'w'
454+
expect(editor.getCursorBufferPosition()).toEqual [0, 6]
455+
expect(editor.getSelectedText()).toBe "line o"
456+
expect(vimState.mode).toEqual 'visual'

0 commit comments

Comments
 (0)