mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Notify about missing project folders
This commit is contained in:
@@ -1364,6 +1364,7 @@ or use Pane::saveItemAs for programmatic saving.`)
|
||||
const needsProjectPaths = this.project && this.project.getPaths().length === 0
|
||||
const foldersToAddToProject = new Set()
|
||||
const fileLocationsToOpen = []
|
||||
const missingFolders = []
|
||||
|
||||
// Asynchronously fetch stat information about each requested path to open.
|
||||
const locationStats = await Promise.all(
|
||||
@@ -1386,9 +1387,13 @@ or use Pane::saveItemAs for programmatic saving.`)
|
||||
if (stats.isDirectory()) {
|
||||
// Directory: add as a project folder
|
||||
foldersToAddToProject.add(this.project.getDirectoryForProjectPath(pathToOpen).getPath())
|
||||
} else if (stats.isFile() && !location.mustBeDirectory) {
|
||||
// File: add as a file location
|
||||
fileLocationsToOpen.push(location)
|
||||
} else if (stats.isFile()) {
|
||||
if (!location.mustBeDirectory) {
|
||||
// File: add as a file location
|
||||
fileLocationsToOpen.push(location)
|
||||
} else {
|
||||
missingFolders.push(location)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Path does not exist
|
||||
@@ -1397,7 +1402,10 @@ or use Pane::saveItemAs for programmatic saving.`)
|
||||
if (directory) {
|
||||
// Found: add as a project folder
|
||||
foldersToAddToProject.add(directory.getPath())
|
||||
} else if (!location.mustBeDirectory) {
|
||||
} else if (location.mustBeDirectory) {
|
||||
// Not found and must be a directory: add to missing list
|
||||
missingFolders.push(location)
|
||||
} else {
|
||||
// Not found: open as a new file
|
||||
fileLocationsToOpen.push(location)
|
||||
}
|
||||
@@ -1430,6 +1438,33 @@ or use Pane::saveItemAs for programmatic saving.`)
|
||||
await Promise.all(fileOpenPromises)
|
||||
}
|
||||
|
||||
if (missingFolders.length > 0) {
|
||||
let message = 'Unable to open project folder'
|
||||
if (missingFolders.length > 1) {
|
||||
message += 's'
|
||||
}
|
||||
|
||||
let description = 'The '
|
||||
if (missingFolders.length === 1) {
|
||||
description += 'directory `'
|
||||
description += missingFolders[0].pathToOpen
|
||||
description += '` does not exist.'
|
||||
} else if (missingFolders.length === 2) {
|
||||
description += `directories \`${missingFolders[0].pathToOpen}\` `
|
||||
description += `and \`${missingFolders[1].pathToOpen}\` do not exist.`
|
||||
} else {
|
||||
description += 'directories '
|
||||
description += (missingFolders
|
||||
.slice(0, -1)
|
||||
.map(location => location.pathToOpen)
|
||||
.map(pathToOpen => '`' + pathToOpen + '`, ')
|
||||
.join(''))
|
||||
description += 'and `' + missingFolders[missingFolders.length - 1].pathToOpen + '` do not exist.'
|
||||
}
|
||||
|
||||
this.notifications.addWarning(message, {description})
|
||||
}
|
||||
|
||||
ipcRenderer.send('window-command', 'window:locations-opened')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user