mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
'meta-o' presents open dialog.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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: ->
|
||||
|
||||
@@ -60,5 +60,6 @@ body {
|
||||
.ace_editor {
|
||||
position: relative !important;
|
||||
font: 18px Inconsolata, Monaco, Courier !important;
|
||||
-webkit-box-flex: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user