Permalink
Browse files

Move left after exiting insert mode

  • Loading branch information...
1 parent 6084006 commit e9382c740475f9f6f4aa3e67e9c6fa5b80e4d966 @joefiorini committed Feb 27, 2014
Showing with 12 additions and 0 deletions.
  1. +4 −0 lib/vim-state.coffee
  2. +8 −0 spec/vim-state-spec.coffee
@@ -222,6 +222,10 @@ class VimState
activateCommandMode: ->
@mode = 'command'
@submode = null
+
+ if @editorView.is(".insert-mode")
+ @editor.getCursor().moveLeft()
+
@editorView.removeClass('insert-mode visual-mode')
@editorView.addClass('command-mode')
@@ -104,6 +104,13 @@ describe "VimState", ->
describe "with content", ->
beforeEach -> editor.setText("012345\n\nabcdef")
+ describe "when cursor is in the middle of the line", ->
+ beforeEach -> editor.setCursorScreenPosition([0,3])
+
+ it "moves the cursor to the left when exiting insert mode", ->
+ keydown('escape')
+ expect(editor.getCursorScreenPosition()).toEqual [0,2]
+
describe "on a line with content", ->
beforeEach -> editor.setCursorScreenPosition([0, 6])
@@ -122,6 +129,7 @@ describe "VimState", ->
expect(editorView).toHaveClass 'command-mode'
expect(editorView).not.toHaveClass 'insert-mode'
+
describe "visual-mode", ->
beforeEach -> keydown('v')

0 comments on commit e9382c7

Please sign in to comment.