about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2018-05-15 13:56:59 +0200
committertoonn <toonn@toonn.io>2018-05-15 13:56:59 +0200
commit77471381f2f9350c87ed989ded1428712002329a (patch)
tree537a9260c5cf91e3f73a4ccb4b917a39c1368168
parent42c0d2a65b2b370ac20838aa4507a263cdec24b6 (diff)
parenta11c723d0ebc4152d0878a79df25c2282e70c6c5 (diff)
downloadranger-77471381f2f9350c87ed989ded1428712002329a.tar.gz
Merge branch 'allthetabs'
-rw-r--r--ranger/core/actions.py21
-rw-r--r--ranger/core/fm.py4
2 files changed, 18 insertions, 7 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 6bbb35aa..3e488159 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -1186,10 +1186,10 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
     def tab_new(self, path=None, narg=None):
         if narg:
             return self.tab_open(narg, path)
-        for i in range(1, 10):
-            if i not in self.tabs:
-                return self.tab_open(i, path)
-        return None
+        i = 1
+        while i in self.tabs:
+            i += 1
+        return self.tab_open(i, path)
 
     def tab_switch(self, path, create_directory=False):
         """Switches to tab of given path, opening a new tab as necessary.
@@ -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
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index c55a3922..d85dd48c 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -424,5 +424,5 @@ class FM(Actions,  # pylint: disable=too-many-instance-attributes
             if not ranger.args.clean and self.settings.save_tabs_on_exit and len(self.tabs) > 1:
                 with open(self.datapath('tabs'), 'a') as fobj:
                     # Don't save active tab since launching ranger changes the active tab
-                    fobj.write('\0'.join(v.path for t, v in self.tabs.items()
-                                         if t != self.current_tab) + '\0\0')
+                    fobj.write('\0'.join(v.path for t, v in self.tabs.items()) +
+                               '\0\0')