From ae7668078374a6ef30d3a45b29746d7315223761 Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 19 Apr 2018 09:04:04 +0200 Subject: Save all the tabs, including the active tab. Remove the check preventing the active tab from being saved. Fixes #883 --- ranger/core/fm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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') -- cgit 1.4.1-2-gfad0 From ec825cb15005673b9f9092547dbc42bc35ae60bf Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 19 Apr 2018 12:51:58 +0200 Subject: Lift the limit on tabs for :tab_new --- ranger/core/actions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 6bbb35aa..a3aad746 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. -- cgit 1.4.1-2-gfad0 From a11c723d0ebc4152d0878a79df25c2282e70c6c5 Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 19 Apr 2018 12:52:47 +0200 Subject: 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. --- ranger/core/actions.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 -- cgit 1.4.1-2-gfad0