Refactor dd to push a SelectLine operation on top of Delete

Delete expects to compose with a motion, which selects the text to be
deleted. SelectLine slots in cleanly to make dd delete the current line.
This commit is contained in:
Nathan Sobo
2012-01-14 00:46:45 -08:00
parent 83cfe70962
commit 532cc83681
3 changed files with 10 additions and 3 deletions

View File

@@ -80,6 +80,9 @@ class Editor extends Template
deleteChar: ->
@aceEditor.remove 'right'
selectLine: ->
@aceEditor.selection.selectLine()
deleteLine: ->
@aceEditor.removeLines()

View File

@@ -87,4 +87,9 @@ module.exports =
column = nextLineMatch?.index or 0
{ row, column }
SelectLine: class
isComplete: -> true
select: (editor) ->
editor.selectLine()

View File

@@ -71,10 +71,9 @@ class VimMode
delete: () ->
if @topOperator() instanceof op.Delete
@topOperator().complete = true
@processOpStack()
@pushOperator(new op.SelectLine)
else
@pushOperator new op.Delete()
@pushOperator(new op.Delete)
pushOperator: (op) ->
@opStack.push(op)