From d0ed5992cada6ac3f210862c53e2fc9108379e19 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 20 Dec 2011 10:41:31 -0800 Subject: [PATCH] 'meta-o' presents open dialog. --- spec/atom/window-spec.coffee | 25 +++++++++++++++++++++++++ src/atom/window.coffee | 4 ++++ src/stdlib/native.coffee | 6 +----- static/atom.css | 3 ++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/spec/atom/window-spec.coffee b/spec/atom/window-spec.coffee index bad4cc78d..cf2d33503 100644 --- a/spec/atom/window-spec.coffee +++ b/spec/atom/window-spec.coffee @@ -13,3 +13,28 @@ describe "Window", -> spyOn(window.editor, 'save') window.keydown 'meta+s' expect(window.editor.save).toHaveBeenCalled() + + describe 'meta+o', -> + selectedFilePath = null + + beforeEach -> + spyOn(atom.native, 'openPanel').andCallFake -> + selectedFilePath + + it 'presents an open dialog', -> + window.keydown 'meta+o' + expect(atom.native.openPanel).toHaveBeenCalled() + + describe 'when a url is chosen', -> + it 'opens the url in the editor', -> + selectedFilePath = require.resolve 'fixtures/sample.txt' + spyOn(window.editor, 'open').andCallFake (url) -> url + window.keydown 'meta+o' + expect(window.editor.open).toHaveBeenCalledWith(selectedFilePath) + + describe 'when dialog is canceled', -> + it 'does not open the editor', -> + selectedFilePath = null + spyOn(window.editor, 'open').andCallFake() + window.keydown 'meta+o' + expect(window.editor.open).not.toHaveBeenCalled() diff --git a/src/atom/window.coffee b/src/atom/window.coffee index 5177bd02c..596e0d1f6 100644 --- a/src/atom/window.coffee +++ b/src/atom/window.coffee @@ -27,6 +27,10 @@ windowAdditions = if String.fromCharCode(event.which) == 'S' and event.metaKey @editor.save() + if String.fromCharCode(event.which) == 'O' and event.metaKey + url = atom.native.openPanel() + @editor.open(url) if url + unbindKeys: -> $(document).unbind 'keydown' diff --git a/src/stdlib/native.coffee b/src/stdlib/native.coffee index 5709685a0..e6ce3257e 100644 --- a/src/stdlib/native.coffee +++ b/src/stdlib/native.coffee @@ -26,11 +26,7 @@ class Native return null filename = panel.filenames.lastObject localStorage.lastOpenedPath = filename - filename.toString() - - openURL: (url) -> - window.location = url - atom.app.activeWindow.setTitle _.last url.replace(/\/$/,'').split '/' + filename.valueOf() # Returns null or a file path. savePanel: -> diff --git a/static/atom.css b/static/atom.css index 89e225398..08340a825 100644 --- a/static/atom.css +++ b/static/atom.css @@ -60,5 +60,6 @@ body { .ace_editor { position: relative !important; font: 18px Inconsolata, Monaco, Courier !important; - -webkit-box-flex: 1; + width: 100%; + height: 100%; }