mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Use cursor:position-changed to make sure cursor never gets to end of line in command mode.
The exception being an empty line.
This commit is contained in:
@@ -13,7 +13,7 @@ class VimMode
|
||||
requireStylesheet 'vim-mode.css'
|
||||
|
||||
@opStack = []
|
||||
@editor.addClass('command-mode')
|
||||
@activateCommandMode()
|
||||
|
||||
atom.bindKeys '.editor', '<esc>': 'activate-command-mode'
|
||||
@editor.on 'activate-command-mode', => @activateCommandMode()
|
||||
@@ -70,6 +70,11 @@ class VimMode
|
||||
@editor.removeClass('insert-mode')
|
||||
@editor.addClass('command-mode')
|
||||
|
||||
@editor.on 'cursor:position-changed', =>
|
||||
moveCursorBeforeNewline = not @editor.selection.modifyingSelection and @editor.cursor.isOnEOL() and @editor.getCurrentLine().length > 0
|
||||
if moveCursorBeforeNewline
|
||||
@editor.setCursorColumn(@editor.getCurrentLine().length - 1)
|
||||
|
||||
numericPrefix: (e) ->
|
||||
num = parseInt(e.keyEvent.keystroke)
|
||||
if @topOperator() instanceof operators.NumericPrefix
|
||||
|
||||
@@ -4,10 +4,7 @@ class Command
|
||||
|
||||
class DeleteRight extends Command
|
||||
execute: ->
|
||||
@editor.delete()
|
||||
isOnEOL = @editor.getCursorColumn() == @editor.getCurrentLine().length
|
||||
if isOnEOL
|
||||
@editor.setCursorColumn(@editor.getCursorColumn() - 1)
|
||||
@editor.delete() unless @editor.getCurrentLine().length == 0
|
||||
|
||||
module.exports = { DeleteRight }
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ class MoveLeft extends Motion
|
||||
class MoveRight extends Motion
|
||||
execute: ->
|
||||
{column, row} = @editor.getCursorPosition()
|
||||
isOnLastCharachter = @editor.getCursorColumn() == @editor.getCurrentLine().length - 1
|
||||
@editor.moveCursorRight() unless isOnLastCharachter
|
||||
@editor.moveCursorRight()
|
||||
|
||||
class MoveUp extends Motion
|
||||
execute: ->
|
||||
|
||||
Reference in New Issue
Block a user