Skip to content

Commit

Permalink
Prefer a {window} explicitly provided to openPaths()
Browse files Browse the repository at this point in the history
  • Loading branch information
smashwilson committed Apr 10, 2019
1 parent a0f41e7 commit e39b12b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main-process/atom-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -968,11 +968,21 @@ class AtomApplication extends EventEmitter {
const normalizedPathsToOpen = locationsToOpen.map(location => location.pathToOpen).filter(Boolean)

let existingWindow
if (!newWindow && normalizedPathsToOpen.length > 0) {

// Explicitly provided AtomWindow has precedence unless a new window is forced.
if (!newWindow) {
existingWindow = window
}

// If no window is specified, a new window is not forced, and at least one path is provided, locate
// an existing window that contains all paths.
if (!existingWindow && !newWindow && normalizedPathsToOpen.length > 0) {
existingWindow = this.windowForPaths(normalizedPathsToOpen, devMode)
}

if (addToLastWindow && !existingWindow) {
// No window specified, new window not forced, no existing window found, and addition to the last window
// requested. Find the last focused window.
if (!existingWindow && !newWindow && addToLastWindow) {
let lastWindow = window || this.getLastFocusedWindow()
if (lastWindow && lastWindow.devMode === devMode) {
existingWindow = lastWindow
Expand Down

0 comments on commit e39b12b

Please sign in to comment.