Also listen to 'open-file' event in constructor.

The 'open-file' may happen before application is launched.
This commit is contained in:
Cheng Zhao
2013-05-30 21:37:14 +08:00
parent 3cad4ae118
commit 2135de059f

View File

@@ -24,6 +24,15 @@ class AtomApplication
@pathsToOpen ?= []
@windows = []
app.on 'open-file', (event, filePath) =>
event.preventDefault()
if @launched
@openPath filePath
else
# Delay opening until Atom has finished launching, this condition
# happens when user double clicks a file in Finder to open it.
@pathsToOpen.push filePath
app.on 'finish-launching', =>
@launched = true
@@ -146,15 +155,6 @@ class AtomApplication
app.on 'window-all-closed', ->
app.quit()
app.on 'open-file', (event, filePath) =>
event.preventDefault()
if @launched
@openPath filePath
else
# Delay opening until Atom has finished launching, this condition
# happens when user double clicks a file in Finder to open it.
@pathsToOpen.push filePath
ipc.on 'close-without-confirm', (processId, routingId) ->
window = BrowserWindow.fromProcessIdAndRoutingId processId, routingId
window.removeAllListeners 'close'