From e2fa948ac8e541ecefe7fcdfac4f87535486a004 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Fri, 29 Apr 2016 08:20:52 -0700 Subject: [PATCH] :bug: Add support for Mac and Open Folder dialog. --- src/browser/atom-application.coffee | 6 +++--- src/register-default-commands.coffee | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index f39c50ce4..f90afad83 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -255,9 +255,9 @@ class AtomApplication ipcMain.on 'open-command', (event, command, args...) => defaultPath = args[0] if args.length > 0 switch command - when 'application:open' then @promptForPathToOpen('all', getLoadSettings()) + when 'application:open' then @promptForPathToOpen('all', getLoadSettings(), defaultPath) when 'application:open-file' then @promptForPathToOpen('file', getLoadSettings(), defaultPath) - when 'application:open-folder' then @promptForPathToOpen('folder', getLoadSettings()) + when 'application:open-folder' then @promptForPathToOpen('folder', getLoadSettings(), defaultPath) else console.log "Invalid open-command received: " + command ipcMain.on 'window-command', (event, command, args...) -> @@ -688,7 +688,7 @@ class AtomApplication else 'Open' # File dialog defaults to project directory of currently active editor - if path? and type is 'file' + if path? openOptions.defaultPath = path dialog.showOpenDialog(parentWindow, openOptions, callback) diff --git a/src/register-default-commands.coffee b/src/register-default-commands.coffee index b2dc1fd68..74da2786e 100644 --- a/src/register-default-commands.coffee +++ b/src/register-default-commands.coffee @@ -1,6 +1,7 @@ {ipcRenderer} = require 'electron' module.exports = ({commandRegistry, commandInstaller, config, notificationManager}) -> + commandRegistry.add 'atom-workspace', 'pane:show-next-recently-used-item': -> @getModel().getActivePane().activateNextRecentlyUsedItem() 'pane:show-previous-recently-used-item': -> @getModel().getActivePane().activatePreviousRecentlyUsedItem() @@ -31,11 +32,15 @@ module.exports = ({commandRegistry, commandInstaller, config, notificationManage 'application:unhide-all-applications': -> ipcRenderer.send('command', 'application:unhide-all-applications') 'application:new-window': -> ipcRenderer.send('command', 'application:new-window') 'application:new-file': -> ipcRenderer.send('command', 'application:new-file') - 'application:open': -> ipcRenderer.send('open-command', 'application:open') - 'application:open-file': -> + 'application:open': -> + defaultPath = atom.workspace.getActiveTextEditor()?.getPath() ? atom.project.getPaths()?[0] + ipcRenderer.send('open-command', 'application:open', defaultPath) + 'application:open-file': -> defaultPath = atom.workspace.getActiveTextEditor()?.getPath() ? atom.project.getPaths()?[0] ipcRenderer.send('open-command', 'application:open-file', defaultPath) - 'application:open-folder': -> ipcRenderer.send('open-command', 'application:open-folder') + 'application:open-folder': -> + defaultPath = atom.workspace.getActiveTextEditor()?.getPath() ? atom.project.getPaths()?[0] + ipcRenderer.send('open-command', 'application:open-folder', defaultPath) 'application:open-dev': -> ipcRenderer.send('command', 'application:open-dev') 'application:open-safe': -> ipcRenderer.send('command', 'application:open-safe') 'application:add-project-folder': -> atom.addProjectFolder()