about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2018-08-31 22:54:12 +0200
committerWojciech Siewierski <wojciech.siewierski@onet.pl>2018-08-31 22:54:12 +0200
commit2c04e3364f94c80ecf2f39681b5f380b351fb101 (patch)
tree6b38c525ce7b86c8a672bb69540ab9b5400aff2e /ranger
parenta34b0ae846a1388b9fada761b06436e058b2d6a4 (diff)
downloadranger-2c04e3364f94c80ecf2f39681b5f380b351fb101.tar.gz
Fix the tilde support in the titlebar
Previously it was possible to have "/home/user" as one's home and
enter "/home/user2", which gets incorrectly abbreviated to "~2/".  Now
such case is left intact, as expected.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/gui/ui.py4
-rw-r--r--ranger/gui/widgets/titlebar.py5
2 files changed, 6 insertions, 3 deletions
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index f357e29d..441e9032 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -365,7 +365,9 @@ class UI(  # pylint: disable=too-many-instance-attributes,too-many-public-method
         DisplayableContainer.draw(self)
         if self._draw_title and self.settings.update_title:
             cwd = self.fm.thisdir.path
-            if self.settings.tilde_in_titlebar and cwd.startswith(self.fm.home_path):
+            if self.settings.tilde_in_titlebar \
+               and (cwd == self.fm.home_path
+                    or cwd.startswith(self.fm.home_path + "/")):
                 cwd = '~' + cwd[len(self.fm.home_path):]
             if self.settings.shorten_title:
                 split = cwd.rsplit(os.sep, self.settings.shorten_title)
diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py
index 042b4b04..765c1248 100644
--- a/ranger/gui/widgets/titlebar.py
+++ b/ranger/gui/widgets/titlebar.py
@@ -102,8 +102,9 @@ class TitleBar(Widget):
             bar.add(' ', 'hostname', clr, fixed=True)
 
         pathway = self.fm.thistab.pathway
-        if self.settings.tilde_in_titlebar and \
-                self.fm.thisdir.path.startswith(self.fm.home_path):
+        if self.settings.tilde_in_titlebar \
+           and (self.fm.thisdir.path.startswith(self.fm.home_path + "/")
+                or self.fm.thisdir.path == self.fm.home_path):
             pathway = pathway[self.fm.home_path.count('/') + 1:]
             bar.add('~/', 'directory', fixed=True)