mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
@@ -14,14 +14,24 @@ describe "Workspace", ->
|
||||
describe "when the 'searchAllPanes' option is false (default)", ->
|
||||
describe "when called without a uri", ->
|
||||
it "adds and activates an empty editor on the active pane", ->
|
||||
editor = null
|
||||
[editor1, editor2] = []
|
||||
|
||||
waitsForPromise ->
|
||||
workspace.open().then (o) -> editor = o
|
||||
workspace.open().then (editor) -> editor1 = editor
|
||||
|
||||
runs ->
|
||||
expect(editor.getPath()).toBeUndefined()
|
||||
expect(workspace.activePane.items).toEqual [editor]
|
||||
expect(workspace.activePaneItem).toBe editor
|
||||
expect(editor1.getPath()).toBeUndefined()
|
||||
expect(workspace.activePane.items).toEqual [editor1]
|
||||
expect(workspace.activePaneItem).toBe editor1
|
||||
expect(workspace.activePane.activate).toHaveBeenCalled()
|
||||
|
||||
waitsForPromise ->
|
||||
workspace.open().then (editor) -> editor2 = editor
|
||||
|
||||
runs ->
|
||||
expect(editor2.getPath()).toBeUndefined()
|
||||
expect(workspace.activePane.items).toEqual [editor1, editor2]
|
||||
expect(workspace.activePaneItem).toBe editor2
|
||||
expect(workspace.activePane.activate).toHaveBeenCalled()
|
||||
|
||||
describe "when called with a uri", ->
|
||||
|
||||
@@ -73,7 +73,7 @@ class Workspace extends Model
|
||||
# if the uri is already open (default: false)
|
||||
#
|
||||
# Returns a promise that resolves to the {Editor} for the file URI.
|
||||
open: (uri='', options={}) ->
|
||||
open: (uri, options={}) ->
|
||||
searchAllPanes = options.searchAllPanes
|
||||
split = options.split
|
||||
uri = atom.project.resolve(uri)
|
||||
@@ -112,8 +112,8 @@ class Workspace extends Model
|
||||
openUriInPane: (uri, pane, options={}) ->
|
||||
changeFocus = options.changeFocus ? true
|
||||
|
||||
item = pane.itemForUri(uri)
|
||||
if uri
|
||||
if uri?
|
||||
item = pane.itemForUri(uri)
|
||||
item ?= opener(atom.project.resolve(uri), options) for opener in @getOpeners() when !item
|
||||
item ?= atom.project.open(uri, options)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user