mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
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:
@@ -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())
|
||||
|
||||
|
||||
@@ -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", ->
|
||||
|
||||
Reference in New Issue
Block a user