summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2018-04-19 12:52:47 +0200
committertoonn <toonn@toonn.io>2018-04-19 13:59:55 +0200
commita11c723d0ebc4152d0878a79df25c2282e70c6c5 (patch)
treef59ac2ee122040a7e62888ba344ae909a7541983 /ranger
parentec825cb15005673b9f9092547dbc42bc35ae60bf (diff)
downloadranger-a11c723d0ebc4152d0878a79df25c2282e70c6c5.tar.gz
Remove the implicit assumption tabs are numbers.
Only get_tab_list() implicitly assumed that tab keys are numbers, or at
least homogeneous. This assumption has now been removed by using a
simple ordering class that orders numbers as expected but anything else
lexically.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/actions.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index a3aad746..3e488159 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -1237,7 +1237,18 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
 
     def get_tab_list(self):
         assert self.tabs, "There must be at least 1 tab at all times"
-        return sorted(self.tabs)
+
+        class NaturalOrder(object):  # pylint: disable=too-few-public-methods
+            def __init__(self, obj):
+                self.obj = obj
+
+            def __lt__(self, other):
+                try:
+                    return self.obj < other.obj
+                except TypeError:
+                    return str(self.obj) < str(other.obj)
+
+        return sorted(self.tabs, key=NaturalOrder)
 
     # --------------------------
     # -- Overview of internals