mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Map h to MoveRight
This commit is contained in:
@@ -119,6 +119,13 @@ describe "VimMode", ->
|
||||
editor.trigger keydownEvent('h')
|
||||
expect(editor.getPosition()).toEqual(column: 0, row: 1)
|
||||
|
||||
describe "the j keybinding", ->
|
||||
it "moves the cursor down, but not to the end of the last line", ->
|
||||
editor.trigger keydownEvent 'j'
|
||||
expect(editor.getPosition()).toEqual(column: 1, row: 2)
|
||||
editor.trigger keydownEvent 'j'
|
||||
expect(editor.getPosition()).toEqual(column: 1, row: 2)
|
||||
|
||||
describe "the k keybinding", ->
|
||||
it "moves the cursor up, but not to the beginning of the first line", ->
|
||||
editor.trigger keydownEvent('k')
|
||||
@@ -126,12 +133,13 @@ describe "VimMode", ->
|
||||
editor.trigger keydownEvent('k')
|
||||
expect(editor.getPosition()).toEqual(column: 1, row: 0)
|
||||
|
||||
describe "the j keybinding", ->
|
||||
it "moves the cursor down, but not to the end of the last line", ->
|
||||
editor.trigger keydownEvent 'j'
|
||||
expect(editor.getPosition()).toEqual(column: 1, row: 2)
|
||||
editor.trigger keydownEvent 'j'
|
||||
expect(editor.getPosition()).toEqual(column: 1, row: 2)
|
||||
fdescribe "the l keybinding", ->
|
||||
it "moves the cursor right, but not to the next line", ->
|
||||
editor.setPosition(column: 4, row: 1)
|
||||
editor.trigger keydownEvent('l')
|
||||
expect(editor.getPosition()).toEqual(column: 5, row: 1)
|
||||
editor.trigger keydownEvent('l')
|
||||
expect(editor.getPosition()).toEqual(column: 5, row: 1)
|
||||
|
||||
describe "the w keybinding", ->
|
||||
it "moves the cursor to the beginning of the next word", ->
|
||||
|
||||
@@ -89,6 +89,9 @@ class Editor extends Template
|
||||
moveLeft: ->
|
||||
@aceEditor.navigateLeft()
|
||||
|
||||
moveRight: ->
|
||||
@aceEditor.navigateRight()
|
||||
|
||||
moveUp: ->
|
||||
@aceEditor.navigateUp()
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ class VimMode
|
||||
'h': 'move-left'
|
||||
'j': 'move-down'
|
||||
'k': 'move-up'
|
||||
'l': 'move-right'
|
||||
'w': 'move-to-next-word'
|
||||
|
||||
@handleCommands
|
||||
@@ -41,6 +42,7 @@ class VimMode
|
||||
'move-left': => new motions.MoveLeft(@editor)
|
||||
'move-up': => new motions.MoveUp(@editor)
|
||||
'move-down': => new motions.MoveDown @editor
|
||||
'move-right': => new motions.MoveRight @editor
|
||||
'move-to-next-word': => new motions.MoveToNextWord(@editor)
|
||||
'numeric-prefix': (e) => @numericPrefix(e)
|
||||
|
||||
|
||||
@@ -14,6 +14,12 @@ class MoveLeft extends Motion
|
||||
position.column-- if position.column > 0
|
||||
@editor.selectToPosition position
|
||||
|
||||
class MoveRight extends Motion
|
||||
execute: ->
|
||||
{column, row} = @editor.getPosition()
|
||||
currentLineLength = @editor.getLineText(row).length
|
||||
@editor.moveRight() if column < currentLineLength
|
||||
|
||||
class MoveUp extends Motion
|
||||
execute: ->
|
||||
{column, row} = @editor.getPosition()
|
||||
@@ -59,5 +65,5 @@ class SelectLines extends Motion
|
||||
@editor.setPosition(column: 0, row: @editor.getRow())
|
||||
@editor.selectToPosition(column: 0, row: @editor.getRow() + @count)
|
||||
|
||||
module.exports = { MoveLeft, MoveUp, MoveDown, MoveToNextWord, SelectLines }
|
||||
module.exports = { MoveLeft, MoveRight, MoveUp, MoveDown, MoveToNextWord, SelectLines }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user