summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xranger/config/commands.py13
-rw-r--r--ranger/core/actions.py29
2 files changed, 19 insertions, 23 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 98cf0cdf..eb4ee4c3 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -548,23 +548,14 @@ class delete(Command):
                 partial(self._question_callback, files), ('n', 'N', 'y', 'Y'))
         else:
             # no need for a confirmation, just delete
-            self._delete_with_tags(files)
+            self.fm.delete(files)
 
     def tab(self, tabnum):
         return self._tab_directory_content()
 
-    def _delete_with_tags(self, files):
-        # Delete the selected files and untag them.
-        absolute_files = [os.path.abspath(f) for f in files]
-        for f in absolute_files:
-            for tag in self.fm.tags.tags:
-                if str(tag).startswith(os.path.abspath(f)):
-                    self.fm.tags.remove(tag)
-        self.fm.delete(absolute_files)
-
     def _question_callback(self, files, answer):
         if answer == 'y' or answer == 'Y':
-            self._delete_with_tags(files)
+            self.fm.delete(files)
 
 
 class mark_tag(Command):
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index e45326f3..a9618746 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -1309,19 +1309,24 @@ class Actions(FileManagerAware, SettingsAware):
     def delete(self, files):
         # XXX: warn when deleting mount points/unseen marked files?
         self.notify("Deleting!")
+        files = [os.path.abspath(f) for f in files]
+        for f in files:
+            # Untag the deleted files.
+            for tag in self.fm.tags.tags:
+                if str(tag).startswith(f):
+                    self.fm.tags.remove(tag)
         self.copy_buffer = set(filter(lambda f: f.path not in files, self.copy_buffer))
-        if files:
-            for f in files:
-                if isdir(f) and not os.path.islink(f):
-                    try:
-                        shutil.rmtree(f)
-                    except OSError as err:
-                        self.notify(err)
-                else:
-                    try:
-                        os.remove(f)
-                    except OSError as err:
-                        self.notify(err)
+        for f in files:
+            if isdir(f) and not os.path.islink(f):
+                try:
+                    shutil.rmtree(f)
+                except OSError as err:
+                    self.notify(err)
+            else:
+                try:
+                    os.remove(f)
+                except OSError as err:
+                    self.notify(err)
         self.thistab.ensure_correct_pointer()
 
     def mkdir(self, name):