@@ -16,6 +16,18 @@ def delete(self, index):
1616 except OSError as e :
1717 sublime .error_message ("Unable to send to trash: {}" .format (e ))
1818 raise OSError ("Unable to send {0!r} to trash: {1}" .format (path , e ))
19+ if index > 1 :
20+ view = self .window .find_open_file (self .paths [index - 2 ])
21+ if view is not None :
22+ close_view (view )
23+
24+ # We substract two, because 0, 1 are populated by Confirm, Cancel
25+ self .paths .remove (self .paths [index - 2 ])
26+
27+ if self .paths :
28+ refresh_sidebar (self .settings , self .window )
29+ self .run (self .paths )
30+
1931 refresh_sidebar (self .settings , self .window )
2032
2133 def run (self , paths = None , * args , ** kwargs ):
@@ -25,17 +37,23 @@ def run(self, paths=None, *args, **kwargs):
2537
2638 self .paths = paths or [self .view .file_name ()]
2739 if get_settings ().get ("ask_for_confirmation_on_delete" ) is not False :
40+ nitems = "{0} " .format (len (self .paths )) if len (self .paths ) > 1 else ""
41+ extras = "s" if len (self .paths ) > 1 else ""
42+
43+ confirm_title = "Confirm"
44+ confirm_subtitle = "Send {}item{} to trash" .format (nitems , extras )
45+ cancel_title = "Cancel All (Select an individual item to remove it from the deletion list)"
46+ cancel_subtitle = "Cancel deletion of {}item{}" .format (nitems , extras )
47+
48+ paths_to_display = [
49+ [confirm_title , confirm_subtitle ],
50+ [cancel_title , cancel_subtitle ],
51+ ]
52+ for path in paths :
53+ paths_to_display .append ([os .path .basename (path ), path ])
54+
2855 self .window .show_quick_panel (
29- [
30- [
31- "Send item{0} to trash" .format (
32- ("s" if len (self .paths ) > 1 else "" )
33- )
34- ]
35- + self .paths ,
36- "Cancel" ,
37- ],
38- self .delete ,
56+ paths_to_display , self .delete ,
3957 )
4058 else :
4159 # index 0 is like clicking on the first option of the panel
0 commit comments