mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Focus tree view after creating a directory
This commit is contained in:
@@ -12,7 +12,7 @@ class Dialog extends View
|
||||
|
||||
initialize: ({path, @onConfirm, select} = {}) ->
|
||||
@miniEditor.focus()
|
||||
@on 'tree-view:confirm', => @confirm()
|
||||
@on 'tree-view:confirm', => @onConfirm(@miniEditor.getText())
|
||||
@on 'tree-view:cancel', => @cancel()
|
||||
@miniEditor.on 'focusout', => @remove()
|
||||
|
||||
@@ -24,8 +24,7 @@ class Dialog extends View
|
||||
range = [[0, path.length - baseName.length], [0, path.length - extension.length]]
|
||||
@miniEditor.setSelectedBufferRange(range)
|
||||
|
||||
confirm: ->
|
||||
return if @onConfirm(@miniEditor.getText()) is false
|
||||
close: ->
|
||||
@remove()
|
||||
$('#root-view').focus()
|
||||
|
||||
|
||||
@@ -206,9 +206,9 @@ class TreeView extends View
|
||||
try
|
||||
fs.makeTree(directoryPath) unless fs.exists(directoryPath)
|
||||
fs.move(oldPath, newPath)
|
||||
dialog.close()
|
||||
catch e
|
||||
dialog.showError("Error: " + e.message + " Try a different path:")
|
||||
return false
|
||||
|
||||
@rootView.append(dialog)
|
||||
|
||||
@@ -242,15 +242,15 @@ class TreeView extends View
|
||||
if fs.exists(path)
|
||||
pathType = if fs.isFile(path) then "file" else "directory"
|
||||
dialog.showError("Error: A #{pathType} already exists at path '#{path}'. Try a different path:")
|
||||
false
|
||||
else if endsWithDirectorySeperator
|
||||
fs.makeTree(path)
|
||||
dialog.cancel()
|
||||
else
|
||||
fs.write(path, "")
|
||||
@rootView.open(path)
|
||||
dialog.close()
|
||||
catch e
|
||||
dialog.showError("Error: " + e.message + " Try a different path:")
|
||||
return false
|
||||
|
||||
@rootView.append(dialog)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user