diff --git a/src/atom-application.coffee b/src/atom-application.coffee index 0bed5e128..b3fc70596 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -130,8 +130,7 @@ class AtomApplication @on 'application:hide-other-applications', -> Menu.sendActionToFirstResponder('hideOtherApplications:') @on 'application:unhide-all-applications', -> Menu.sendActionToFirstResponder('unhideAllApplications:') @on 'application:new-window', -> - [width, height] = @focusedWindow()?.getSize() ? [] - @openPath(initialSize: {width, height}) + @openPath(initialSize: @getFocusedWindowSize()) @on 'application:new-file', -> (@focusedWindow() ? this).openPath() @on 'application:open', -> @promptForPath() @on 'application:open-dev', -> @promptForPath(devMode: true) @@ -197,6 +196,17 @@ class AtomApplication focusedWindow: -> _.find @windows, (atomWindow) -> atomWindow.isFocused() + # Public: Get the height and width of the focused window. + # + # Returns an object with height and width keys or null if there is no + # focused window. + getFocusedWindowSize: -> + if focusedWindow = @focusedWindow() + [width, height] = focusedWindow.getSize() + {width, height} + else + null + # Public: Opens multiple paths, in existing windows if possible. # # * options @@ -282,7 +292,7 @@ class AtomApplication if pack.urlMain packagePath = @packages.resolvePackagePath(packageName) bootstrapScript = path.resolve(packagePath, pack.urlMain) - new AtomWindow({bootstrapScript, @resourcePath, devMode, urlToOpen}) + new AtomWindow({bootstrapScript, @resourcePath, devMode, urlToOpen, initialSize: getFocusedWindowSize()}) else console.log "Package '#{pack.name}' does not have a url main: #{urlToOpen}" else