mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Merge pull request #17021 from atom/aw/d-d-d-double-open
Synchronously track URIs in the process of opening
This commit is contained in:
commit
d4185b2b01
@ -274,6 +274,21 @@ describe('Workspace', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('discovers existing editors that are still opening', () => {
|
||||
let editor0 = null
|
||||
let editor1 = null
|
||||
|
||||
waitsForPromise(() => Promise.all([
|
||||
workspace.open('spartacus.txt').then(o0 => { editor0 = o0 }),
|
||||
workspace.open('spartacus.txt').then(o1 => { editor1 = o1 }),
|
||||
]))
|
||||
|
||||
runs(() => {
|
||||
expect(editor0).toEqual(editor1)
|
||||
expect(workspace.getActivePane().items).toEqual([editor0])
|
||||
})
|
||||
})
|
||||
|
||||
it("uses the location specified by the model's `getDefaultLocation()` method", () => {
|
||||
const item = {
|
||||
getDefaultLocation: jasmine.createSpy().andReturn('right'),
|
||||
@ -361,6 +376,28 @@ describe('Workspace', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('discovers existing editors that are still opening in an inactive pane', () => {
|
||||
let editor0 = null
|
||||
let editor1 = null
|
||||
const pane0 = workspace.getActivePane()
|
||||
const pane1 = workspace.getActivePane().splitRight()
|
||||
|
||||
pane0.activate()
|
||||
const promise0 = workspace.open('spartacus.txt', {searchAllPanes: true}).then(o0 => { editor0 = o0 })
|
||||
pane1.activate()
|
||||
const promise1 = workspace.open('spartacus.txt', {searchAllPanes: true}).then(o1 => { editor1 = o1 })
|
||||
|
||||
waitsForPromise(() => Promise.all([promise0, promise1]))
|
||||
|
||||
runs(() => {
|
||||
expect(editor0).toBeDefined()
|
||||
expect(editor1).toBeDefined()
|
||||
|
||||
expect(editor0).toEqual(editor1)
|
||||
expect(workspace.getActivePane().items).toEqual([editor0])
|
||||
})
|
||||
})
|
||||
|
||||
it('activates the pane in the dock with the matching item', () => {
|
||||
const dock = atom.workspace.getRightDock()
|
||||
const ITEM_URI = 'atom://test'
|
||||
|
@ -225,6 +225,8 @@ module.exports = class Workspace extends Model {
|
||||
modal: new PanelContainer({viewRegistry: this.viewRegistry, location: 'modal'})
|
||||
}
|
||||
|
||||
this.incoming = new Map()
|
||||
|
||||
this.subscribeToEvents()
|
||||
}
|
||||
|
||||
@ -921,6 +923,17 @@ module.exports = class Workspace extends Model {
|
||||
if (typeof item.getURI === 'function') uri = item.getURI()
|
||||
}
|
||||
|
||||
let resolveItem = () => {}
|
||||
if (uri) {
|
||||
const incomingItem = this.incoming.get(uri)
|
||||
if (!incomingItem) {
|
||||
this.incoming.set(uri, new Promise(resolve => { resolveItem = resolve }))
|
||||
} else {
|
||||
await incomingItem
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!atom.config.get('core.allowPendingPaneItems')) {
|
||||
options.pending = false
|
||||
}
|
||||
@ -1048,6 +1061,12 @@ module.exports = class Workspace extends Model {
|
||||
|
||||
const index = pane.getActiveItemIndex()
|
||||
this.emitter.emit('did-open', {uri, pane, item, index})
|
||||
if (uri) {
|
||||
this.incoming.delete(uri)
|
||||
}
|
||||
} finally {
|
||||
resolveItem()
|
||||
}
|
||||
return item
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user