mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Can enter multi-digit numeric prefixes in command mode.
This commit is contained in:
@@ -64,7 +64,7 @@ describe "VimMode", ->
|
||||
editor.trigger keydownEvent('j')
|
||||
expect(editor.getCursor()).toEqual(column: 1, row: 0)
|
||||
|
||||
describe "numeric prefix binding", ->
|
||||
describe "numeric prefix bindings", ->
|
||||
it "repeats the following operation N times", ->
|
||||
editor.buffer.setText("12345")
|
||||
editor.setCursor(column: 1, row: 0)
|
||||
@@ -74,6 +74,14 @@ describe "VimMode", ->
|
||||
|
||||
expect(editor.buffer.getText()).toBe '15'
|
||||
|
||||
editor.buffer.setText("123456789abc")
|
||||
editor.setCursor(column: 0, row: 0)
|
||||
editor.trigger keydownEvent('1')
|
||||
editor.trigger keydownEvent('0')
|
||||
editor.trigger keydownEvent('x')
|
||||
|
||||
expect(editor.buffer.getText()).toBe 'bc'
|
||||
|
||||
describe "insert-mode", ->
|
||||
beforeEach ->
|
||||
editor.trigger keydownEvent('i')
|
||||
|
||||
@@ -14,6 +14,9 @@ module.exports =
|
||||
|
||||
isComplete: -> @complete
|
||||
|
||||
addDigit: (digit) ->
|
||||
@count = @count * 10 + digit
|
||||
|
||||
execute: (editor) ->
|
||||
_.times @count, => @operatorToRepeat.execute(editor)
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class VimMode
|
||||
eventName = "command-mode:#{commandName}"
|
||||
@editor.on eventName, (e) =>
|
||||
possibleOperator = fn(e)
|
||||
@pushOperator(possibleOperator) if possibleOperator.execute?
|
||||
@pushOperator(possibleOperator) if possibleOperator?.execute
|
||||
|
||||
activateInsertMode: ->
|
||||
@editor.removeClass('command-mode')
|
||||
@@ -60,7 +60,10 @@ class VimMode
|
||||
|
||||
numericPrefix: (e) ->
|
||||
num = parseInt(e.keyEvent.keystroke)
|
||||
new op.NumericPrefix(num)
|
||||
if @topOperator() instanceof op.NumericPrefix
|
||||
@topOperator().addDigit(num)
|
||||
else
|
||||
@pushOperator(new op.NumericPrefix(num))
|
||||
|
||||
pushOperator: (op) ->
|
||||
@opStack.push(op)
|
||||
|
||||
Reference in New Issue
Block a user