mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-19 23:17:16 +03:00
Don't report missing project folder errors twice
This commit is contained in:
parent
2b1aaa7a13
commit
f1e0843473
@ -336,57 +336,34 @@ describe('AtomEnvironment', () => {
|
||||
})
|
||||
|
||||
describe('deserialization failures', () => {
|
||||
it('propagates project state restoration failures', async () => {
|
||||
it('propagates unrecognized project state restoration failures', async () => {
|
||||
let err
|
||||
spyOn(atom.project, 'deserialize').andCallFake(() => {
|
||||
const err = new Error('deserialization failure')
|
||||
err.missingProjectPaths = ['/foo']
|
||||
err = new Error('deserialization failure')
|
||||
return Promise.reject(err)
|
||||
})
|
||||
spyOn(atom.notifications, 'addError')
|
||||
|
||||
await atom.deserialize({ project: 'should work' })
|
||||
expect(atom.notifications.addError).toHaveBeenCalledWith(
|
||||
'Unable to open project directory',
|
||||
'Unable to deserialize project',
|
||||
{
|
||||
description: 'Project directory `/foo` is no longer on disk.'
|
||||
description: 'deserialization failure',
|
||||
stack: err.stack
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('accumulates and reports two errors with one notification', async () => {
|
||||
it('disregards missing project folder errors', async () => {
|
||||
spyOn(atom.project, 'deserialize').andCallFake(() => {
|
||||
const err = new Error('deserialization failure')
|
||||
err.missingProjectPaths = ['/foo', '/wat']
|
||||
err.missingProjectPaths = ['nah']
|
||||
return Promise.reject(err)
|
||||
})
|
||||
spyOn(atom.notifications, 'addError')
|
||||
|
||||
await atom.deserialize({ project: 'should work' })
|
||||
expect(atom.notifications.addError).toHaveBeenCalledWith(
|
||||
'Unable to open 2 project directories',
|
||||
{
|
||||
description:
|
||||
'Project directories `/foo` and `/wat` are no longer on disk.'
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('accumulates and reports three+ errors with one notification', async () => {
|
||||
spyOn(atom.project, 'deserialize').andCallFake(() => {
|
||||
const err = new Error('deserialization failure')
|
||||
err.missingProjectPaths = ['/foo', '/wat', '/stuff', '/things']
|
||||
return Promise.reject(err)
|
||||
})
|
||||
spyOn(atom.notifications, 'addError')
|
||||
|
||||
await atom.deserialize({ project: 'should work' })
|
||||
expect(atom.notifications.addError).toHaveBeenCalledWith(
|
||||
'Unable to open 4 project directories',
|
||||
{
|
||||
description:
|
||||
'Project directories `/foo`, `/wat`, `/stuff`, and `/things` are no longer on disk.'
|
||||
}
|
||||
)
|
||||
expect(atom.notifications.addError).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -1247,9 +1247,8 @@ or use Pane::saveItemAs for programmatic saving.`)
|
||||
try {
|
||||
await this.project.deserialize(state.project, this.deserializers)
|
||||
} catch (error) {
|
||||
if (error.missingProjectPaths) {
|
||||
missingProjectPaths.push(...error.missingProjectPaths)
|
||||
} else {
|
||||
// We handle the missingProjectPaths case in openLocations().
|
||||
if (!error.missingProjectPaths) {
|
||||
this.notifications.addError('Unable to deserialize project', {
|
||||
description: error.message,
|
||||
stack: error.stack
|
||||
@ -1268,7 +1267,7 @@ or use Pane::saveItemAs for programmatic saving.`)
|
||||
|
||||
if (missingProjectPaths.length > 0) {
|
||||
const count = missingProjectPaths.length === 1 ? '' : missingProjectPaths.length + ' '
|
||||
const noun = missingProjectPaths.length === 1 ? 'directory' : 'directories'
|
||||
const noun = missingProjectPaths.length === 1 ? 'folder' : 'folders'
|
||||
const toBe = missingProjectPaths.length === 1 ? 'is' : 'are'
|
||||
const escaped = missingProjectPaths.map(projectPath => `\`${projectPath}\``)
|
||||
let group
|
||||
|
Loading…
Reference in New Issue
Block a user