mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
File finder opens selected file in the most recent pane.
Only editors inside #root-view #panes are tracked as the most recent active editor. Otherwise the file finder tries to open the selected file in its own mini editor.
This commit is contained in:
@@ -161,7 +161,7 @@ describe "RootView", ->
|
||||
editor = rootView.find('.editor:has(:focus)').view()
|
||||
editor.trigger 'split-up'
|
||||
|
||||
row1 = rootView.children(':eq(0)')
|
||||
row1 = rootView.panes.children(':eq(0)')
|
||||
expect(row1.children().length).toBe 2
|
||||
column1 = row1.children(':eq(0)')
|
||||
editor1 = row1.children(':eq(1)')
|
||||
@@ -280,16 +280,14 @@ describe "RootView", ->
|
||||
expect(rootView.find('.file-finder')).not.toExist()
|
||||
|
||||
it "shows all relative file paths for the current project", ->
|
||||
waitsForPromise ->
|
||||
rootView.resultOfTrigger 'toggle-file-finder'
|
||||
rootView.trigger 'toggle-file-finder'
|
||||
|
||||
waitsForPromise ->
|
||||
project.getFilePaths().done (paths) ->
|
||||
expect(rootView.fileFinder.urlList.children('li').length).toBe paths.length
|
||||
project.getFilePaths().done (paths) ->
|
||||
expect(rootView.fileFinder.urlList.children('li').length).toBe paths.length
|
||||
|
||||
for path in paths
|
||||
relativePath = path.replace(project.url, '')
|
||||
expect(rootView.fileFinder.urlList.find("li:contains(#{relativePath}):not(:contains(#{project.url}))")).toExist()
|
||||
for path in paths
|
||||
relativePath = path.replace(project.url, '')
|
||||
expect(rootView.fileFinder.urlList.find("li:contains(#{relativePath}):not(:contains(#{project.url}))")).toExist()
|
||||
|
||||
describe "when there is no project", ->
|
||||
beforeEach ->
|
||||
@@ -303,11 +301,23 @@ describe "RootView", ->
|
||||
|
||||
describe "when a path is selected in the file finder", ->
|
||||
it "opens the file associated with that path in the editor", ->
|
||||
waitsForPromise -> rootView.resultOfTrigger 'toggle-file-finder'
|
||||
runs ->
|
||||
firstLi = rootView.fileFinder.find('li:first')
|
||||
rootView.fileFinder.trigger 'select'
|
||||
expect(rootView.editor.buffer.url).toBe(project.url + firstLi.text())
|
||||
rootView.attachToDom()
|
||||
rootView.find('.editor').trigger 'split-right'
|
||||
[editor1, editor2] = rootView.find('.editor').map -> $(this).view()
|
||||
|
||||
rootView.trigger 'toggle-file-finder'
|
||||
rootView.fileFinder.trigger 'move-down'
|
||||
selectedLi = rootView.fileFinder.find('li:eq(1)')
|
||||
|
||||
expectedUrl = project.url + selectedLi.text()
|
||||
expect(editor1.buffer.url).not.toBe expectedUrl
|
||||
expect(editor2.buffer.url).not.toBe expectedUrl
|
||||
|
||||
# debugger
|
||||
rootView.fileFinder.trigger 'file-finder:select-file'
|
||||
|
||||
expect(editor1.buffer.url).not.toBe expectedUrl
|
||||
expect(editor2.buffer.url).toBe expectedUrl
|
||||
|
||||
describe "global keymap wiring", ->
|
||||
commandHandler = null
|
||||
|
||||
@@ -13,7 +13,8 @@ module.exports =
|
||||
class RootView extends View
|
||||
@content: ->
|
||||
@div id: 'root-view', =>
|
||||
@subview 'editor', new Editor
|
||||
@div id: 'panes', outlet: 'panes', =>
|
||||
@subview 'editor', new Editor
|
||||
|
||||
editors: null
|
||||
|
||||
@@ -40,21 +41,23 @@ class RootView extends View
|
||||
@append(view)
|
||||
|
||||
editorFocused: (editor) ->
|
||||
_.remove(@editors, editor)
|
||||
@editors.push(editor)
|
||||
if @panes.containsElement(editor)
|
||||
_.remove(@editors, editor)
|
||||
@editors.push(editor)
|
||||
|
||||
editorRemoved: (editor) ->
|
||||
_.remove(@editors, editor)
|
||||
@adjustSplitPanes()
|
||||
if @editors.length
|
||||
@focusLastActiveEditor()
|
||||
else
|
||||
window.close()
|
||||
if @panes.containsElement
|
||||
_.remove(@editors, editor)
|
||||
@adjustSplitPanes()
|
||||
if @editors.length
|
||||
@lastActiveEditor().focus()
|
||||
else
|
||||
window.close()
|
||||
|
||||
focusLastActiveEditor: ->
|
||||
_.last(@editors).focus()
|
||||
lastActiveEditor: ->
|
||||
_.last(@editors)
|
||||
|
||||
adjustSplitPanes: (element = @children(':first'))->
|
||||
adjustSplitPanes: (element = @panes.children(':first'))->
|
||||
if element.hasClass('row')
|
||||
totalUnits = @horizontalGridUnits(element)
|
||||
unitsSoFar = 0
|
||||
@@ -109,11 +112,12 @@ class RootView extends View
|
||||
if @fileFinder and @fileFinder.parent()[0]
|
||||
@fileFinder.remove()
|
||||
@fileFinder = null
|
||||
@focusLastActiveEditor()
|
||||
@lastActiveEditor().focus()
|
||||
else
|
||||
@project.getFilePaths().done (paths) =>
|
||||
relativePaths = (path.replace(@project.url, "") for path in paths)
|
||||
@fileFinder = new FileFinder
|
||||
urls: relativePaths
|
||||
selected: (relativePath) => @editor.setBuffer(@project.open(relativePath))
|
||||
selected: (relativePath) =>
|
||||
@lastActiveEditor().setBuffer(@project.open(relativePath))
|
||||
@addPane @fileFinder
|
||||
|
||||
@@ -16,6 +16,11 @@ body {
|
||||
background-image: url(static/images/linen.png);
|
||||
}
|
||||
|
||||
#root-view #panes {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.column {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
|
||||
Reference in New Issue
Block a user