Default ranges to empty array when no edit session

Previously an exception would be thrown if a '/' pattern was evaluated
when there was no active edit session.
This commit is contained in:
Kevin Sawicki
2013-04-19 10:05:48 -07:00
parent b4ab10403d
commit 36768251f8
2 changed files with 12 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ class CompositeCommand
constructor: (@subcommands) ->
execute: (project, editSession) ->
currentRanges = editSession?.getSelectedBufferRanges()
currentRanges = editSession?.getSelectedBufferRanges() ? []
@executeCommands(@subcommands, project, editSession, currentRanges)
executeCommands: (commands, project, editSession, ranges) ->
@@ -60,4 +60,3 @@ class CompositeCommand
isRelativeAddress: ->
_.all(@subcommands, (command) -> command.isAddress() and command.isRelative())

View File

@@ -205,6 +205,17 @@ describe "CommandInterpreter", ->
runs ->
expect(interpreter.lastRelativeAddress.subcommands[0].regex.toString()).toEqual "/Array/"
describe "when there is no active edit session", ->
it "returns no error messages and does not throw an error", ->
errorMessages = null
waitsForPromise ->
interpreter.eval('/something').done (results) ->
{errorMessages} = results
runs ->
expect(errorMessages.length).toBe 0
describe "address range", ->
describe "when two addresses are specified", ->
it "selects from the begining of the left address to the end of the right address", ->