Can enter multi-digit numeric prefixes in command mode.

This commit is contained in:
Nathan Sobo
2012-01-13 14:49:25 -08:00
parent b4886bb6d6
commit 712475569d
3 changed files with 17 additions and 3 deletions

View File

@@ -14,6 +14,9 @@ module.exports =
isComplete: -> @complete
addDigit: (digit) ->
@count = @count * 10 + digit
execute: (editor) ->
_.times @count, => @operatorToRepeat.execute(editor)

View File

@@ -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)