From ea48ae626c7211dfb75b9be49785e00a2d43b36e Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Mon, 6 Feb 2012 10:38:56 -0800 Subject: [PATCH] l can't move the cursor past the last character. --- spec/atom/vim-mode-spec.coffee | 8 ++++---- src/atom/vim-mode/motions.coffee | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/atom/vim-mode-spec.coffee b/spec/atom/vim-mode-spec.coffee index 98f4278f0..83b3f93a9 100644 --- a/spec/atom/vim-mode-spec.coffee +++ b/spec/atom/vim-mode-spec.coffee @@ -1,7 +1,7 @@ Editor = require 'editor' VimMode = require 'vim-mode' -describe "VimMode", -> +fdescribe "VimMode", -> editor = null beforeEach -> @@ -149,11 +149,11 @@ describe "VimMode", -> describe "the l keybinding", -> it "moves the cursor right, but not to the next line", -> - editor.setCursorPosition([1,4]) + editor.setCursorPosition([1,3]) editor.trigger keydownEvent('l') - expect(editor.getCursorPosition()).toEqual([1,5]) + expect(editor.getCursorPosition()).toEqual([1,4]) editor.trigger keydownEvent('l') - expect(editor.getCursorPosition()).toEqual([1,5]) + expect(editor.getCursorPosition()).toEqual([1,4]) describe "the w keybinding", -> it "moves the cursor to the beginning of the next word", -> diff --git a/src/atom/vim-mode/motions.coffee b/src/atom/vim-mode/motions.coffee index 655b28980..1f374e30a 100644 --- a/src/atom/vim-mode/motions.coffee +++ b/src/atom/vim-mode/motions.coffee @@ -17,8 +17,9 @@ class MoveLeft extends Motion class MoveRight extends Motion execute: -> {column, row} = @editor.getCursorPosition() - currentLineLength = @editor.buffer.getLine(row).length - @editor.moveCursorRight() if column < currentLineLength + console.log @editor.getCurrentLine().length + isOnLastCharachter = @editor.getCursorColumn() == @editor.getCurrentLine().length - 1 + @editor.moveCursorRight() unless isOnLastCharachter class MoveUp extends Motion execute: ->