Skip to content

Loading…

Move left after exiting insert mode #48

Merged
merged 1 commit into from

3 participants

@joefiorini

This matches actual Vim behavior. If I go into insert mode and ESC over and over again, the cursor should keep moving left.

@lodestone

Strange but true...

@joefiorini

Realized I forgot to write a test for this. Are there any instructions for getting a custom build to run tests against?

@joefiorini

Figured out testing. All I had to do was run apm test with my vim-mode fork as cwd. Tests are now included.

@mcolyer mcolyer commented on an outdated diff
spec/vim-state-spec.coffee
@@ -122,6 +129,7 @@ describe "VimState", ->
expect(editorView).toHaveClass 'command-mode'
expect(editorView).not.toHaveClass 'insert-mode'
+
@mcolyer
mcolyer added a note

Can you nuke this extra new line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@joefiorini

Whoops, yeah.

@joefiorini

I mean, what blank line? :wink:

@mcolyer mcolyer added the bug label
@mcolyer

Thanks, I'll merge now.

@mcolyer mcolyer merged commit d6cb25f into atom:master
@mcolyer mcolyer added a commit that referenced this pull request
@mcolyer mcolyer Add a changelog note for #48 fcb7e68
@chadkouse chadkouse added a commit to chadkouse/vim-mode that referenced this pull request
@chadkouse chadkouse Merge branch 'master' into linewisePaste
* master: (27 commits)
  Tiny fix for CHANGELOG
  Tiny fix for README
  Revert pull request #94
  Bump Atom dependency to latest (0.62)
  Prepare 0.7.2 release
  Mark changelog as 0.7.2
  Add spec for selection behavior in command-mode
  Remove extra whitespace
  Add changelog notes for #81 & #84
  Revert pull request #92
  Add changelog note for #59
  Add changelog notes for #76
  Fix a test failure on 0.62
  Add gt, gT keybindings to switch tabs
  motion: added { for movement to previous paragraph
  Update changelog for #71
  Document existing commands
  Add documentation for #49
  Add a changelog note for #48
  Move left after exiting insert mode
  ...
e8caeaf
@mcolyer

@joefiorini can you take a look at #115?

@MarkusSN MarkusSN pushed a commit to MarkusSN/vim-mode that referenced this pull request
@mcolyer mcolyer Add a changelog note for #48 ed69eae
@MarkusSN MarkusSN pushed a commit to MarkusSN/vim-mode that referenced this pull request
@chadkouse chadkouse Merge branch 'master' into linewisePaste
* master: (27 commits)
  Tiny fix for CHANGELOG
  Tiny fix for README
  Revert pull request #94
  Bump Atom dependency to latest (0.62)
  Prepare 0.7.2 release
  Mark changelog as 0.7.2
  Add spec for selection behavior in command-mode
  Remove extra whitespace
  Add changelog notes for #81 & #84
  Revert pull request #92
  Add changelog note for #59
  Add changelog notes for #76
  Fix a test failure on 0.62
  Add gt, gT keybindings to switch tabs
  motion: added { for movement to previous paragraph
  Update changelog for #71
  Document existing commands
  Add documentation for #49
  Add a changelog note for #48
  Move left after exiting insert mode
  ...
b213d4c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 28, 2014
  1. @joefiorini
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 0 deletions.
  1. +4 −0 lib/vim-state.coffee
  2. +7 −0 spec/vim-state-spec.coffee
View
4 lib/vim-state.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')
View
7 spec/vim-state-spec.coffee
@@ -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])
Something went wrong with that request. Please try again.