diff --git a/src/extensions/command-panel/commands/address.coffee b/src/extensions/command-panel/commands/address.coffee index 594d4a52d..7949a379d 100644 --- a/src/extensions/command-panel/commands/address.coffee +++ b/src/extensions/command-panel/commands/address.coffee @@ -3,7 +3,8 @@ Operation = require 'command-panel/operation' module.exports = class Address extends Command - compile: (project, buffer, range) -> - [new Operation(buffer: buffer, bufferRange: @getRange(buffer, range))] + compile: (project, buffer, ranges) -> + ranges.map (range) => + new Operation(buffer: buffer, bufferRange: @getRange(buffer, range)) isAddress: -> true diff --git a/src/extensions/command-panel/commands/composite-command.coffee b/src/extensions/command-panel/commands/composite-command.coffee index 2ae072f50..b6a10c37f 100644 --- a/src/extensions/command-panel/commands/composite-command.coffee +++ b/src/extensions/command-panel/commands/composite-command.coffee @@ -8,9 +8,7 @@ class CompositeCommand currentRanges = editSession.getSelectedBufferRanges() for command in @subcommands operations?.forEach (o) -> o.destroy() - operations = [] - for range in currentRanges - operations.push(command.compile(project, editSession.buffer, range)...) + operations = command.compile(project, editSession.buffer, currentRanges) currentRanges = operations.map (o) -> o.getBufferRange() editSession.clearAllSelections() unless command.preserveSelections diff --git a/src/extensions/command-panel/commands/select-all-matches.coffee b/src/extensions/command-panel/commands/select-all-matches.coffee index 471646f4b..eb828f0ac 100644 --- a/src/extensions/command-panel/commands/select-all-matches.coffee +++ b/src/extensions/command-panel/commands/select-all-matches.coffee @@ -8,8 +8,9 @@ class SelectAllMatches extends Command constructor: (pattern) -> @regex = new RegExp(pattern, 'g') - compile: (project, buffer, range) -> + compile: (project, buffer, ranges) -> operations = [] - buffer.scanInRange @regex, range, (match, matchRange) -> - operations.push(new Operation(buffer: buffer, bufferRange: matchRange)) + for range in ranges + buffer.scanInRange @regex, range, (match, matchRange) -> + operations.push(new Operation(buffer: buffer, bufferRange: matchRange)) operations diff --git a/src/extensions/command-panel/commands/substitution.coffee b/src/extensions/command-panel/commands/substitution.coffee index 9940c1ed1..046beda20 100644 --- a/src/extensions/command-panel/commands/substitution.coffee +++ b/src/extensions/command-panel/commands/substitution.coffee @@ -11,13 +11,14 @@ class Substitution extends Command @replacementText = replacementText @regex = new RegExp(pattern, options.join('')) - compile: (project, buffer, range) -> + compile: (project, buffer, ranges) -> operations = [] - buffer.scanInRange @regex, range, (match, matchRange, { replace }) => - operations.push(new Operation( - buffer: buffer, - bufferRange: matchRange, - newText: @replacementText - preserveSelection: true - )) + for range in ranges + buffer.scanInRange @regex, range, (match, matchRange, { replace }) => + operations.push(new Operation( + buffer: buffer, + bufferRange: matchRange, + newText: @replacementText + preserveSelection: true + )) operations