mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-19 06:58:26 +03:00
Merge pull request #14108 from atom/fb-mdt-remember-moved-item-positions
🐛 Fix observation of moved items
This commit is contained in:
commit
32ff2f37d9
@ -2326,6 +2326,23 @@ i = /test/; #FIXME\
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when an item is moved', () => {
|
||||
it('stores the new location', () => {
|
||||
const ITEM_URI = 'atom://test'
|
||||
const item = {
|
||||
getURI: () => ITEM_URI,
|
||||
getDefaultLocation: jasmine.createSpy().andReturn('left'),
|
||||
getElement: () => document.createElement('div')
|
||||
}
|
||||
const centerPane = workspace.getActivePane()
|
||||
centerPane.addItem(item)
|
||||
const dockPane = atom.workspace.getRightDock().getActivePane()
|
||||
spyOn(workspace.itemLocationStore, 'save')
|
||||
centerPane.moveItemToPane(item, dockPane)
|
||||
expect(workspace.itemLocationStore.save).toHaveBeenCalledWith(ITEM_URI, 'right')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
const escapeStringRegex = str => str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
||||
|
@ -296,13 +296,15 @@ module.exports = class Workspace extends Model {
|
||||
|
||||
subscribeToMovedItems () {
|
||||
for (const paneContainer of this.getPaneContainers()) {
|
||||
paneContainer.onDidAddPaneItem(({item}) => {
|
||||
if (typeof item.getURI === 'function') {
|
||||
const uri = item.getURI()
|
||||
if (uri != null) {
|
||||
this.itemLocationStore.save(item.getURI(), paneContainer.getLocation())
|
||||
paneContainer.observePanes(pane => {
|
||||
pane.onDidAddItem(({item}) => {
|
||||
if (typeof item.getURI === 'function') {
|
||||
const uri = item.getURI()
|
||||
if (uri != null) {
|
||||
this.itemLocationStore.save(item.getURI(), paneContainer.getLocation())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user