From 462bd77ad5c49ea2d5d3137bfa6030d2a28fb046 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 25 May 2013 14:38:04 +0800 Subject: [PATCH] Make atom.open work with parameters. --- src/app/atom.coffee | 7 ++----- src/atom-application.coffee | 10 ++++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/app/atom.coffee b/src/app/atom.coffee index a84b28ba0..32997d15f 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -153,11 +153,8 @@ window.atom = themeNames = config.get("core.themes") ? ['atom-dark-ui', 'atom-dark-syntax'] themeNames = [themeNames] unless _.isArray(themeNames) - open: (url) -> - if url - throw new Error('opening a url does not currently work', url) - else - ipc.sendChannel('open-folder') + open: (url...) -> + ipc.sendChannel('open', [url...]) openDev: (url) -> console.error("atom.openDev does not work yet") diff --git a/src/atom-application.coffee b/src/atom-application.coffee index a842028fb..26c6b2548 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -155,10 +155,12 @@ class AtomApplication ipc.on 'open-config', => @openConfig() - ipc.on 'open-folder', => - currentWindow = BrowserWindow.getFocusedWindow() - pathsToOpen = dialog.showOpenDialog title: 'Open', properties: ['openFile', 'openDirectory', 'multiSelections', 'createDirectory'] - @open(pathToOpen) for pathToOpen in pathsToOpen if pathsToOpen? + ipc.on 'open', (processId, routingId, pathsToOpen) => + if not pathsToOpen + pathsToOpen = dialog.showOpenDialog title: 'Open', properties: ['openFile', 'openDirectory', 'multiSelections', 'createDirectory'] + @open(pathsToOpen) if pathsToOpen? + else + @open(pathsToOpen) ipc.on 'new-window', => @open()