Files
atom/src/extensions/command-interpreter/composite-command.coffee
2012-04-23 10:54:56 -06:00

18 lines
552 B
CoffeeScript

_ = require 'underscore'
module.exports =
class CompositeCommand
constructor: (@subcommands) ->
execute: (editor) ->
for command in @subcommands
newRanges = []
currentRanges = editor.getSelectionsOrderedByBufferPosition().map (selection) -> selection.getBufferRange()
for currentRange in currentRanges
newRanges.push(command.execute(editor, currentRange)...)
editor.setSelectedBufferRanges(newRanges)
isRelativeAddress: ->
_.all(@subcommands, (command) -> command.isAddress() and command.isRelative())