mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-19 23:17:16 +03:00
openLocations() flag to require a path to be an existing directory
This commit is contained in:
parent
5a82278b8f
commit
f6837d1f97
@ -669,6 +669,21 @@ describe('AtomEnvironment', () => {
|
||||
expect(atom.workspace.getTextEditors().map(e => e.getPath())).toEqual([pathToOpen])
|
||||
expect(atom.project.getPaths()).toEqual([])
|
||||
})
|
||||
|
||||
it('may be required to be an existing directory', async () => {
|
||||
const nonExistent = path.join(__dirname, 'no')
|
||||
const existingFile = __filename
|
||||
const existingDir = path.join(__dirname, 'fixtures')
|
||||
|
||||
await atom.openLocations([
|
||||
{pathToOpen: nonExistent, mustBeDirectory: true},
|
||||
{pathToOpen: existingFile, mustBeDirectory: true},
|
||||
{pathToOpen: existingDir, mustBeDirectory: true}
|
||||
])
|
||||
|
||||
expect(atom.workspace.getTextEditors()).toEqual([])
|
||||
expect(atom.project.getPaths()).toEqual([existingDir])
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the opened path is handled by a registered directory provider', () => {
|
||||
|
@ -1386,7 +1386,7 @@ 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()) {
|
||||
} else if (stats.isFile() && !location.mustBeDirectory) {
|
||||
// File: add as a file location
|
||||
fileLocationsToOpen.push(location)
|
||||
}
|
||||
@ -1397,7 +1397,7 @@ or use Pane::saveItemAs for programmatic saving.`)
|
||||
if (directory) {
|
||||
// Found: add as a project folder
|
||||
foldersToAddToProject.add(directory.getPath())
|
||||
} else {
|
||||
} else if (!location.mustBeDirectory) {
|
||||
// Not found: open as a new file
|
||||
fileLocationsToOpen.push(location)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user