summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2019-12-27 19:06:20 +0100
committertoonn <toonn@toonn.io>2019-12-27 19:20:06 +0100
commitfba70c637f47b1e43ed21e37f65ee4750f71b320 (patch)
tree62d70bcf79dda8dfb2332943a4a1e16d8e0e4ad3 /ranger
parentf87f7d26f31cf2690ff2ed4129102d7b2cd86bba (diff)
downloadranger-fba70c637f47b1e43ed21e37f65ee4750f71b320.tar.gz
Fix fuzzy tab completion when prefix is valid dir
Fuzzy tab completion was dropping the entire valid prefix instead of
showing the path relative to the current directory.

```
/ $ cd usr/sh<tab>
/ $ cd share/      # `usr/` is dropped because it's already a valid
                   # directory.
/ $ cd usr/share/  # Proper result with the fix.
```

Fixes #1792
Diffstat (limited to 'ranger')
-rwxr-xr-xranger/config/commands.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 06d5abb7..c2a02b67 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -243,8 +243,9 @@ class cd(Command):
 
         paths = self._tab_fuzzy_match(basepath, tokens)
         if not os.path.isabs(dest):
-            paths_rel = basepath
-            paths = [os.path.relpath(path, paths_rel) for path in paths]
+            paths_rel = self.fm.thisdir.path
+            paths = [os.path.relpath(os.path.join(basepath, path), paths_rel)
+                     for path in paths]
         else:
             paths_rel = ''
         return paths, paths_rel