diff options
author | toonn <toonn@toonn.io> | 2021-09-06 22:26:10 +0200 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2021-09-06 22:26:10 +0200 |
commit | 99771df4d7ec71b45976bdc85be66c30b725d14e (patch) | |
tree | dddf80df892f850736f585703549ed6db1dbc64c | |
parent | 46abf8c9fa439de921886a7aed2e4d2e8251b6fd (diff) | |
download | ranger-99771df4d7ec71b45976bdc85be66c30b725d14e.tar.gz |
commands: Fix off-by-one shift in setinpath/regex
Rather than complicating the matter by adding 1 to shift the specific set command (not sure why this works for me in testing, since `parse_setting_from_line` already drops the command) and then taking the minimum of the length of the path and 1 because of the "path=" bit that's always present, even if the path is an empty string, we just recreate the argument, substituting "=" for "path=", and iterate over the whitespace seperated parts and shift once for each.
-rwxr-xr-x | ranger/config/commands.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 07052687..43c4993f 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -520,7 +520,9 @@ class setlocal_(set_): if not match: return None path = match.group(1) - for _ in range(1 + min(1, len(path.split()))): + # Prepend something that behaves like "path=" in case path starts with + # whitespace + for _ in "={0}".format(path).split(): self.shift() return os.path.expanduser(path) |