x will not allow the newline to be deleted

This commit is contained in:
Corey Johnson 2012-02-06 10:19:17 -08:00
parent 824af2bc03
commit dd9723e256
2 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,7 @@
Editor = require 'editor'
VimMode = require 'vim-mode'
describe "VimMode", ->
fdescribe "VimMode", ->
editor = null
beforeEach ->
@ -37,13 +37,16 @@ describe "VimMode", ->
describe "the x keybinding", ->
it "deletes a charachter", ->
editor.buffer.setText("12345")
editor.setCursorPosition([0, 1])
editor.buffer.setText("012345")
editor.setCursorPosition([0, 4])
editor.trigger keydownEvent('x')
expect(editor.buffer.getText()).toBe '01235'
expect(editor.getCursorPosition()).toEqual([0, 4])
expect(editor.buffer.getText()).toBe '1345'
expect(editor.getCursorPosition()).toEqual([0, 1])
editor.trigger keydownEvent('x')
expect(editor.buffer.getText()).toBe '0123'
expect(editor.getCursorPosition()).toEqual([0, 3])
describe "the d keybinding", ->
describe "when followed by a d", ->

View File

@ -4,7 +4,10 @@ class Command
class DeleteRight extends Command
execute: ->
@editor.deleteRight()
@editor.delete()
isOnLastCharachter = @editor.getCursorColumn() == @editor.getCurrentLine().length
if isOnLastCharachter
@editor.setCursorColumn(@editor.getCursorColumn() - 1)
module.exports = { DeleteRight }