Refactor repeatRelativeAddress/repeatRelativeAddressInReverse

This commit is contained in:
probablycorey
2013-03-26 16:43:19 -07:00
parent 2ffb88e936
commit f817e37a01
2 changed files with 9 additions and 10 deletions

View File

@@ -11,8 +11,10 @@ class CommandInterpreter
@lastRelativeAddress = compositeCommand if compositeCommand.isRelativeAddress()
compositeCommand.execute(@project, activeEditSession)
repeatRelativeAddress: (activeEditSession) ->
@lastRelativeAddress?.execute(@project, activeEditSession)
repeatRelativeAddress: (activeEditSession, {reverse}={}) ->
return unless @lastRelativeAddress
reverse ?= false
previousSelectionRange = activeEditSession.getSelection().getBufferRange()
address = if reverse then @lastRelativeAddress.reverse() else @lastRelativeAddress
repeatRelativeAddressInReverse: (activeEditSession) ->
@lastRelativeAddress?.reverse().execute(@project, activeEditSession)
address.execute(@project, activeEditSession)

View File

@@ -44,7 +44,7 @@ class CommandPanelView extends View
rootView.command 'command-panel:find-in-file', => @attach('/')
rootView.command 'command-panel:find-in-project', => @attach('Xx/')
rootView.command 'command-panel:repeat-relative-address', => @repeatRelativeAddress()
rootView.command 'command-panel:repeat-relative-address-in-reverse', => @repeatRelativeAddressInReverse()
rootView.command 'command-panel:repeat-relative-address-in-reverse', => @repeatRelativeAddress(reverse: true)
rootView.command 'command-panel:set-selection-as-regex-address', => @setSelectionAsLastRelativeAddress()
@on 'click', '.expand', @onExpandAll
@@ -157,11 +157,8 @@ class CommandPanelView extends View
@historyIndex++
@miniEditor.setText(@history[@historyIndex] or '')
repeatRelativeAddress: ->
@commandInterpreter.repeatRelativeAddress(rootView.getActivePaneItem())
repeatRelativeAddressInReverse: ->
@commandInterpreter.repeatRelativeAddressInReverse(rootView.getActivePaneItem())
repeatRelativeAddress: (options) ->
@commandInterpreter.repeatRelativeAddress(rootView.getActivePaneItem(), options)
setSelectionAsLastRelativeAddress: ->
selection = rootView.getActiveView().getSelectedText()