Merge pull request #19231 from atom/aw/no-focus-dev-mode

Skip dev mode windows when choosing an existing window for an open action
This commit is contained in:
Ash Wilson
2019-04-28 20:32:21 -04:00
committed by GitHub
2 changed files with 16 additions and 3 deletions

View File

@@ -675,6 +675,18 @@ describe('AtomApplication', function () {
assert.isNull(w._locations[0].initialLine)
assert.isNull(w._locations[0].initialColumn)
})
it('disregards test and benchmark windows', async function () {
await scenario.launch(parseCommandLine(['--test', 'b']))
await scenario.open(parseCommandLine(['--new-window']))
await scenario.open(parseCommandLine(['--test', 'c']))
await scenario.open(parseCommandLine(['--benchmark', 'b']))
await scenario.open(parseCommandLine(['a/1.md']))
// Test and benchmark StubWindows are visible as empty editor windows here
await scenario.assert('[_ _] [_ 1.md] [_ _] [_ _]')
})
})
if (process.platform === 'darwin' || process.platform === 'win32') {

View File

@@ -866,6 +866,7 @@ class AtomApplication extends EventEmitter {
// Returns the {AtomWindow} for the given locations.
windowForLocations (locationsToOpen, devMode, safeMode) {
return this.getLastFocusedWindow(window =>
!window.isSpec &&
window.devMode === devMode &&
window.safeMode === safeMode &&
window.containsLocations(locationsToOpen)
@@ -1021,13 +1022,13 @@ class AtomApplication extends EventEmitter {
// focused window that matches the requested dev and safe modes.
if (!existingWindow && addToLastWindow) {
existingWindow = this.getLastFocusedWindow(win => {
return win.devMode === devMode && win.safeMode === safeMode
return !win.isSpec && win.devMode === devMode && win.safeMode === safeMode
})
}
// Fall back to the last focused window that has no project roots.
if (!existingWindow) {
existingWindow = this.getLastFocusedWindow(win => !win.hasProjectPaths())
existingWindow = this.getLastFocusedWindow(win => !win.isSpec && !win.hasProjectPaths())
}
// One last case: if *no* paths are directories, add to the last focused window.
@@ -1035,7 +1036,7 @@ class AtomApplication extends EventEmitter {
const noDirectories = locationsToOpen.every(location => !location.isDirectory)
if (noDirectories) {
existingWindow = this.getLastFocusedWindow(win => {
return win.devMode === devMode && win.safeMode === safeMode
return !win.isSpec && win.devMode === devMode && win.safeMode === safeMode
})
}
}