FileFinder is toggleable

This commit is contained in:
Corey Johnson & Nathan Sobo 2011-12-28 15:53:54 -08:00
parent d181ce1885
commit c6fbad8e9e
3 changed files with 20 additions and 8 deletions

View File

@ -3,7 +3,7 @@ FileFinder = require 'file-finder'
describe 'FileFinder', ->
finder = null
beforeEach ->
beforeEach ->
urls = ['app.coffee', 'buffer.coffee', 'atom/app.coffee', 'atom/buffer.coffee']
finder = FileFinder.build {urls}
@ -12,7 +12,7 @@ describe 'FileFinder', ->
expect(finder.urlList.find('li')).not.toExist()
finder.input.val('ap')
finder.input.keypress()
finder.input.keyup()
expect(finder.urlList.children().length).toBe 2
expect(finder.urlList.find('li:contains(app.coffee)').length).toBe 2
@ -20,7 +20,7 @@ describe 'FileFinder', ->
# we should clear the list before re-populating it
finder.input.val('a/ap')
finder.input.keypress()
finder.input.keyup()
expect(finder.urlList.children().length).toBe 1
expect(finder.urlList.find('li:contains(atom/app.coffee)').length).toBe 1

View File

@ -93,6 +93,14 @@ describe "Window", ->
it "adds a Save item to the main menu after startup", ->
expect(OSX.NSApp.mainMenu.itemWithTitle('File').submenu.itemWithTitle('Save')).not.toBeNull()
describe "toggleFileFinder", ->
it "shows the FileFinder when it is not on screen and hides it when it is", ->
expect(window.layout.find('.file-finder')).not.toExist()
window.toggleFileFinder()
expect(window.layout.find('.file-finder')).toExist()
window.toggleFileFinder()
expect(window.layout.find('.file-finder')).not.toExist()
describe 'meta+s', ->
it 'saves the buffer', ->
spyOn(window.editor, 'save')

View File

@ -32,15 +32,19 @@ windowAdditions =
$(window).unbind('blur')
$(window).unbind('keydown')
findFile: ->
fileFinder = FileFinder.build(urls: [@editor.buffer.url])
window.layout.addPane(fileFinder)
fileFinder.input.focus()
toggleFileFinder: ->
if @fileFinder
@fileFinder.remove()
@fileFinder = null
else
@fileFinder = FileFinder.build(urls: [@editor.buffer.url])
window.layout.addPane(fileFinder)
fileFinder.input.focus()
bindKeys: ->
@bindKey 'meta+s', => @editor.save()
@bindKey 'meta+w', => @close()
@bindKey 'meta+t', => @findFile()
@bindKey 'meta+t', => @toggleFileFinder()
bindMenuItems: ->
@bindMenuItem "File > Save", "meta+s", => @editor.save()