mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add repeat-relative-address-in-reverse event to command panel
This commit is contained in:
@@ -14,3 +14,5 @@ class CommandInterpreter
|
||||
repeatRelativeAddress: (editor) ->
|
||||
@lastRelativeAddress?.execute(editor)
|
||||
|
||||
repeatRelativeAddressInReverse: (editor) ->
|
||||
@lastRelativeAddress?.reverse().execute(editor)
|
||||
|
||||
@@ -12,6 +12,9 @@ class CompositeCommand
|
||||
newRanges.push(command.execute(editor, currentRange)...)
|
||||
editor.setSelectedBufferRanges(newRanges)
|
||||
|
||||
reverse: ->
|
||||
new CompositeCommand(@subcommands.map (command) -> command.reverse())
|
||||
|
||||
isRelativeAddress: ->
|
||||
_.all(@subcommands, (command) -> command.isAddress() and command.isRelative())
|
||||
|
||||
|
||||
@@ -31,3 +31,6 @@ class RegexAddress extends Address
|
||||
rangeToReturn or currentRange
|
||||
|
||||
isRelative: -> true
|
||||
|
||||
reverse: ->
|
||||
new RegexAddress(@regex, !@isReversed)
|
||||
@@ -42,6 +42,7 @@ class CommandPanel extends View
|
||||
@rootView.on 'command-panel:execute', => @execute()
|
||||
@rootView.on 'command-panel:find-in-file', => @show("/")
|
||||
@rootView.on 'command-panel:repeat-relative-address', => @repeatRelativeAddress()
|
||||
@rootView.on 'command-panel:repeat-relative-address-in-reverse', => @repeatRelativeAddressInReverse()
|
||||
@rootView.on 'command-panel:set-selection-as-regex-address', => @setSelectionAsLastRelativeAddress()
|
||||
|
||||
@miniEditor.off 'move-up move-down'
|
||||
@@ -88,6 +89,9 @@ class CommandPanel extends View
|
||||
repeatRelativeAddress: ->
|
||||
@commandInterpreter.repeatRelativeAddress(@rootView.activeEditor())
|
||||
|
||||
repeatRelativeAddressInReverse: ->
|
||||
@commandInterpreter.repeatRelativeAddressInReverse(@rootView.activeEditor())
|
||||
|
||||
setSelectionAsLastRelativeAddress: ->
|
||||
selection = @rootView.activeEditor().getSelectedText()
|
||||
regex = _.escapeRegExp(selection)
|
||||
|
||||
Reference in New Issue
Block a user