mirror of
https://github.com/atom/atom.git
synced 2026-02-09 06:05:11 -05:00
Implement d3d
Delete line can take a count before the second d. When the second d is typed it pushed a SelectLines operation. When a numeric prefix is composed with SelectLines, it assigns its count on select lines, which uses it to determine how many lines to select. This bypasses the normal "repeat command" semantics of numeric prefix.
This commit is contained in:
@@ -74,11 +74,16 @@ class VimMode
|
||||
@pushOperator(new operators.NumericPrefix(num))
|
||||
|
||||
delete: () ->
|
||||
if @topOperator() instanceof operators.Delete
|
||||
@pushOperator(new motions.SelectLine(@editor))
|
||||
if @isDeletePending()
|
||||
@pushOperator(new motions.SelectLines(@editor))
|
||||
else
|
||||
@pushOperator(new operators.Delete(@editor))
|
||||
|
||||
isDeletePending: () ->
|
||||
for op in @opStack
|
||||
return true if op instanceof operators.Delete
|
||||
false
|
||||
|
||||
pushOperator: (op) ->
|
||||
@opStack.push(op)
|
||||
@processOpStack()
|
||||
|
||||
@@ -47,9 +47,17 @@ class MoveToNextWord extends Motion
|
||||
column = nextLineMatch?.index or 0
|
||||
{ row, column }
|
||||
|
||||
class SelectLine extends Motion
|
||||
class SelectLines extends Motion
|
||||
count: null
|
||||
|
||||
constructor: (@editor) ->
|
||||
@count = 1
|
||||
|
||||
setCount: (@count) ->
|
||||
|
||||
select: ->
|
||||
@editor.selectLine()
|
||||
@editor.setPosition(column: 0, row: @editor.getRow())
|
||||
@editor.selectToPosition(column: 0, row: @editor.getRow() + @count)
|
||||
|
||||
module.exports = { MoveLeft, MoveUp, MoveDown, MoveToNextWord, SelectLine }
|
||||
module.exports = { MoveLeft, MoveUp, MoveDown, MoveToNextWord, SelectLines }
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ class NumericPrefix
|
||||
|
||||
compose: (@operatorToRepeat) ->
|
||||
@complete = true
|
||||
if @operatorToRepeat.setCount?
|
||||
@operatorToRepeat.setCount @count
|
||||
@count = 1
|
||||
|
||||
addDigit: (digit) ->
|
||||
@count = @count * 10 + digit
|
||||
|
||||
Reference in New Issue
Block a user