about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2019-03-05 00:12:57 +0100
committertoonn <toonn@toonn.io>2019-03-05 00:12:57 +0100
commitc25ab7a079b6d490b4413ef0e0ffe409a3f1b763 (patch)
treebf2b3305fb81c8ff26f6b7c321bd297f92c57ce6
parent51e7383ad5ebdf35374d62b44ca57ad58ce339cb (diff)
downloadranger-c25ab7a079b6d490b4413ef0e0ffe409a3f1b763.tar.gz
Fix dest check for :paste
The new destination argument for `:paste` requires a guard on whether it
is a valid target. A bug snuck in because of copious negation : )
This is now fixed, we only allow the target to be a directory or `None`
which means the current tab's working directory.
-rw-r--r--ranger/core/actions.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 3868d102..8e98432a 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -1565,13 +1565,13 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
         Paste the selected items into the current directory or to dest
         if provided.
         """
-        if dest is not None:
-            if not exists(dest) and not isdir(dest):
-                self.notify('Failed to paste. The given path is invalid.', bad=True)
-                return
-        loadable = CopyLoader(self.copy_buffer, self.do_cut, overwrite, dest=dest)
-        self.loader.add(loadable, append=append)
-        self.do_cut = False
+        if dest is None or isdir(dest):
+            loadable = CopyLoader(self.copy_buffer, self.do_cut, overwrite,
+                                  dest)
+            self.loader.add(loadable, append=append)
+            self.do_cut = False
+        else:
+            self.notify('Failed to paste. The given path is invalid.', bad=True)
 
     def delete(self, files=None):
         # XXX: warn when deleting mount points/unseen marked files?
hlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
parse/0: instruction: 1
parse/0:   ingredient: {name: "34", value: 0, type: 0, properties: ["34": "literal"]}
parse/0:   product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
parse/0: instruction: 1
parse/0:   ingredient: {name: "34", value: 0, type: 0, properties: ["34": "literal"]}
parse/0:   product: {name: "2", value: 0, type: 1, properties: ["2": "integer"]}
parse/0: instruction: 14
parse/0:   ingredient: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
parse/0:   ingredient: {name: "2", value: 0, type: 1, properties: ["2": "integer"]}
parse/0:   product: {name: "3", value: 0, type: 1, properties: ["3": "integer"]}
after-brace/0: recipe main
after-brace/0: copy ...
after-brace/0: copy ...
after-brace/0: greater-than ...
run/0: instruction main/0
run/0: ingredient 0 is 34
mem/0: storing 34 in location 1
run/0: instruction main/1
run/0: ingredient 0 is 34
mem/0: storing 34 in location 2
run/0: instruction main/2
run/0: ingredient 0 is 1
mem/0: location 1 is 34
run/0: ingredient 1 is 2
mem/0: location 2 is 34
run/0: product 0 is 0
mem/0: storing 0 in location 3