Focus most-recently active editor pane when file finder closes.

This commit is contained in:
Nathan Sobo
2012-03-20 15:11:34 -06:00
parent adf8d5df9d
commit 965e66ffd4
2 changed files with 15 additions and 12 deletions

View File

@@ -262,19 +262,22 @@ describe "RootView", ->
describe "when the toggle-file-finder event is triggered", ->
describe "when there is a project", ->
it "shows the FileFinder when it is not on screen and hides it when it is", ->
runs ->
rootView.attachToDom()
expect(rootView.find('.file-finder')).not.toExist()
rootView.attachToDom()
expect(rootView.find('.file-finder')).not.toExist()
waitsForPromise ->
rootView.resultOfTrigger 'toggle-file-finder'
rootView.find('.editor').trigger 'split-right'
[editor1, editor2] = rootView.find('.editor').map -> $(this).view()
runs ->
expect(rootView.find('.file-finder')).toExist()
expect(rootView.find('.file-finder input:focus')).toExist()
rootView.trigger 'toggle-file-finder'
expect(rootView.find('.editor:has(:focus)')).toExist()
expect(rootView.find('.file-finder')).not.toExist()
rootView.trigger 'toggle-file-finder'
expect(rootView.find('.file-finder')).toExist()
expect(rootView.find('.file-finder input:focus')).toExist()
rootView.trigger 'toggle-file-finder'
expect(editor1.isFocused).toBeFalsy()
expect(editor2.isFocused).toBeTruthy()
expect(rootView.find('.editor:has(:focus)')).toExist()
expect(rootView.find('.file-finder')).not.toExist()
it "shows all relative file paths for the current project", ->
waitsForPromise ->

View File

@@ -109,7 +109,7 @@ class RootView extends View
if @fileFinder and @fileFinder.parent()[0]
@fileFinder.remove()
@fileFinder = null
@editor.focus()
@focusLastActiveEditor()
else
@project.getFilePaths().done (paths) =>
relativePaths = (path.replace(@project.url, "") for path in paths)