mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add to root if no entry is selected
This commit is contained in:
@@ -740,6 +740,17 @@ describe "TreeView", ->
|
||||
|
||||
expect(addDialog.miniEditor.getText().length).toBe 0
|
||||
|
||||
describe "when there is no entry selected", ->
|
||||
it "opens an add dialog with no path populated", ->
|
||||
addDialog.cancel()
|
||||
treeView.root.click()
|
||||
treeView.root.removeClass('selected')
|
||||
expect(treeView.selectedEntry()).toBeUndefined()
|
||||
treeView.trigger "tree-view:add"
|
||||
addDialog = rootView.find(".tree-view-dialog").view()
|
||||
|
||||
expect(addDialog.miniEditor.getText().length).toBe 0
|
||||
|
||||
describe "tree-view:move", ->
|
||||
describe "when a file is selected", ->
|
||||
moveDialog = null
|
||||
|
||||
@@ -239,7 +239,8 @@ class TreeView extends ScrollView
|
||||
)
|
||||
|
||||
add: ->
|
||||
selectedPath = @selectedEntry().getPath()
|
||||
selectedEntry = @selectedEntry() or @root
|
||||
selectedPath = selectedEntry.getPath()
|
||||
directoryPath = if fs.isFile(selectedPath) then fs.directory(selectedPath) else selectedPath
|
||||
relativeDirectoryPath = @rootView.project.relativize(directoryPath)
|
||||
relativeDirectoryPath += '/' if relativeDirectoryPath.length > 0
|
||||
|
||||
Reference in New Issue
Block a user