@@ -598,45 +598,48 @@ class TreeView
598598
599599 for root in @roots
600600 if root .getPath () in selectedPaths
601- atom .confirm
602- message : " The root directory '#{ root .directory .name } ' can't be removed."
601+ atom .confirm ({
602+ message : " The root directory '#{ root .directory .name } ' can't be removed." ,
603603 buttons : [' OK' ]
604+ }, -> # noop
605+ )
604606 return
605607
606- atom .confirm
607- message : " Are you sure you want to delete the selected #{ if selectedPaths .length > 1 then ' items' else ' item' } ?"
608- detailedMessage : " You are deleting:\n #{ selectedPaths .join (' \n ' )} "
609- buttons :
610- " Move to Trash " : =>
611- failedDeletions = []
612- for selectedPath in selectedPaths
613- # Don't delete entries which no longer exist. This can happen, for example, when:
614- # * The entry is deleted outside of Atom before "Move to Trash" is selected
615- # * A folder and one of its children are both selected for deletion,
616- # but the parent folder is deleted first
617- continue unless fs .existsSync (selectedPath)
618-
619- @emitter .emit ' will-delete-entry' , {pathToDelete : selectedPath}
620- if shell .moveItemToTrash (selectedPath)
621- @emitter .emit ' entry-deleted' , {pathToDelete : selectedPath}
622- else
623- @emitter .emit ' delete-entry-failed' , {pathToDelete : selectedPath}
624- failedDeletions .push selectedPath
625-
626- if repo = repoForPath (selectedPath)
627- repo .getPathStatus (selectedPath)
628-
629- if failedDeletions .length > 0
630- atom .notifications .addError @ formatTrashFailureMessage (failedDeletions),
631- description : @ formatTrashEnabledMessage ()
632- detail : " #{ failedDeletions .join (' \n ' )} "
633- dismissable : true
634-
635- # Focus the first parent folder
636- if firstSelectedEntry = selectedEntries[0 ]
637- @ selectEntry (firstSelectedEntry .closest (' .directory:not(.selected)' ))
638- @ updateRoots () if atom .config .get (' tree-view.squashDirectoryNames' )
639- " Cancel" : null
608+ atom .confirm ({
609+ message : " Are you sure you want to delete the selected #{ if selectedPaths .length > 1 then ' items' else ' item' } ?" ,
610+ detailedMessage : " You are deleting:\n #{ selectedPaths .join (' \n ' )} " ,
611+ buttons : [' Move to Trash' , ' Cancel' ]
612+ }, (response ) =>
613+ if response is 0 # Move to Trash
614+ failedDeletions = []
615+ for selectedPath in selectedPaths
616+ # Don't delete entries which no longer exist. This can happen, for example, when:
617+ # * The entry is deleted outside of Atom before "Move to Trash" is selected
618+ # * A folder and one of its children are both selected for deletion,
619+ # but the parent folder is deleted first
620+ continue unless fs .existsSync (selectedPath)
621+
622+ @emitter .emit ' will-delete-entry' , {pathToDelete : selectedPath}
623+ if shell .moveItemToTrash (selectedPath)
624+ @emitter .emit ' entry-deleted' , {pathToDelete : selectedPath}
625+ else
626+ @emitter .emit ' delete-entry-failed' , {pathToDelete : selectedPath}
627+ failedDeletions .push selectedPath
628+
629+ if repo = repoForPath (selectedPath)
630+ repo .getPathStatus (selectedPath)
631+
632+ if failedDeletions .length > 0
633+ atom .notifications .addError @ formatTrashFailureMessage (failedDeletions),
634+ description : @ formatTrashEnabledMessage ()
635+ detail : " #{ failedDeletions .join (' \n ' )} "
636+ dismissable : true
637+
638+ # Focus the first parent folder
639+ if firstSelectedEntry = selectedEntries[0 ]
640+ @ selectEntry (firstSelectedEntry .closest (' .directory:not(.selected)' ))
641+ @ updateRoots () if atom .config .get (' tree-view.squashDirectoryNames' )
642+ )
640643
641644 formatTrashFailureMessage : (failedDeletions ) ->
642645 fileText = if failedDeletions .length > 1 then ' files' else ' file'
0 commit comments