mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
When a file/directory is created, it is selected in the treeview
This commit is contained in:
@@ -310,20 +310,6 @@ describe "TreeView", ->
|
||||
treeView.trigger "tree-view:add"
|
||||
addDialog = rootView.find(".add-dialog").view()
|
||||
|
||||
describe "when a directory is selected", ->
|
||||
it "opens an add dialog with the directory's path populated", ->
|
||||
addDialog.cancel()
|
||||
dirView.click()
|
||||
treeView.trigger "tree-view:add"
|
||||
addDialog = rootView.find(".add-dialog").view()
|
||||
|
||||
expect(addDialog).toExist()
|
||||
expect(addDialog.prompt.text()).toBeTruthy()
|
||||
expect(project.relativize(dirPath)).toMatch(/[^\/]$/)
|
||||
expect(addDialog.miniEditor.getText()).toBe(project.relativize(dirPath) + "/")
|
||||
expect(addDialog.miniEditor.getCursorBufferPosition().column).toBe addDialog.miniEditor.getText().length
|
||||
expect(addDialog.miniEditor.isFocused).toBeTruthy()
|
||||
|
||||
describe "when a file is selected", ->
|
||||
it "opens an add dialog with the file's current directory path populated", ->
|
||||
expect(addDialog).toExist()
|
||||
@@ -333,8 +319,17 @@ describe "TreeView", ->
|
||||
expect(addDialog.miniEditor.getCursorBufferPosition().column).toBe addDialog.miniEditor.getText().length
|
||||
expect(addDialog.miniEditor.isFocused).toBeTruthy()
|
||||
|
||||
describe "when parent directory of the selected file changes", ->
|
||||
it "active file is still shown as selected in the tree view", ->
|
||||
directoryChangeHandler = jasmine.createSpy("directory-change")
|
||||
dirView.on "tree-view:directory-change", directoryChangeHandler
|
||||
|
||||
dirView.directory.trigger 'contents-change'
|
||||
expect(directoryChangeHandler).toHaveBeenCalled()
|
||||
expect(treeView.find('.selected').text()).toBe fs.base(filePath)
|
||||
|
||||
describe "when the path without a trailing '/' is changed and confirmed", ->
|
||||
it "add a file and closes the dialog", ->
|
||||
it "add a file, closes the dialog and selects the file in the tree-view", ->
|
||||
newPath = fs.join(dirPath, "new-test-file.txt")
|
||||
addDialog.miniEditor.insertText(fs.base(newPath))
|
||||
addDialog.trigger 'tree-view:confirm'
|
||||
@@ -343,6 +338,12 @@ describe "TreeView", ->
|
||||
expect(addDialog.parent()).not.toExist()
|
||||
expect(rootView.activeEditor().buffer.path).toBe newPath
|
||||
|
||||
waitsFor "tree view to be updated", ->
|
||||
dirView.entries.find("> .file").length > 1
|
||||
|
||||
runs ->
|
||||
expect(treeView.find('.selected').text()).toBe fs.base(newPath)
|
||||
|
||||
describe "when the path with a trailing '/' is changed and confirmed", ->
|
||||
it "adds a directory and closes the dialog", ->
|
||||
newPath = fs.join(dirPath, "new-dir")
|
||||
@@ -367,6 +368,20 @@ describe "TreeView", ->
|
||||
expect(addDialog.parent()).not.toExist()
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
|
||||
describe "when a directory is selected", ->
|
||||
it "opens an add dialog with the directory's path populated", ->
|
||||
addDialog.cancel()
|
||||
dirView.click()
|
||||
treeView.trigger "tree-view:add"
|
||||
addDialog = rootView.find(".add-dialog").view()
|
||||
|
||||
expect(addDialog).toExist()
|
||||
expect(addDialog.prompt.text()).toBeTruthy()
|
||||
expect(project.relativize(dirPath)).toMatch(/[^\/]$/)
|
||||
expect(addDialog.miniEditor.getText()).toBe(project.relativize(dirPath) + "/")
|
||||
expect(addDialog.miniEditor.getCursorBufferPosition().column).toBe addDialog.miniEditor.getText().length
|
||||
expect(addDialog.miniEditor.isFocused).toBeTruthy()
|
||||
|
||||
describe "tree-view:move", ->
|
||||
describe "when a file is selected", ->
|
||||
moveDialog = null
|
||||
|
||||
@@ -57,6 +57,7 @@ class DirectoryView extends View
|
||||
watchEntries: ->
|
||||
@directory.on "contents-change.#{@directory.path}", =>
|
||||
@buildEntries()
|
||||
@trigger "tree-view:directory-change"
|
||||
|
||||
unwatchEntries: ->
|
||||
@unwatchDescendantEntries()
|
||||
|
||||
@@ -31,6 +31,7 @@ class TreeView extends View
|
||||
@on 'tree-view:open-selected-entry', => @openSelectedEntry()
|
||||
@on 'tree-view:move', => @move()
|
||||
@on 'tree-view:add', => @add()
|
||||
@on 'tree-view:directory-change', => @selectActiveFile()
|
||||
@rootView.on 'active-editor-path-change', => @selectActiveFile()
|
||||
|
||||
deactivate: ->
|
||||
|
||||
Reference in New Issue
Block a user