diff options
author | mathieui <mathieui@mathieui.net> | 2018-06-30 21:39:31 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2018-07-21 20:20:13 +0200 |
commit | 115aee3d050a44be6223fb7a4f61f786719b32e1 (patch) | |
tree | 5549bf687e432222826380ef8c481c7fd03c20a3 | |
parent | 2147efa4a1f1b033caee3362c637dec00609bee0 (diff) | |
download | poezio-115aee3d050a44be6223fb7a4f61f786719b32e1.tar.gz poezio-115aee3d050a44be6223fb7a4f61f786719b32e1.tar.bz2 poezio-115aee3d050a44be6223fb7a4f61f786719b32e1.tar.xz poezio-115aee3d050a44be6223fb7a4f61f786719b32e1.zip |
new tabs: apply review
-rw-r--r-- | poezio/core/core.py | 2 | ||||
-rw-r--r-- | poezio/core/tabs.py | 23 |
2 files changed, 14 insertions, 11 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py index f6985a56..51f6f41e 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -1098,7 +1098,7 @@ class Core: for state in states: for tab in tab_refs[state]: - if (tab.nb < self.tabs.current_tab_intex and + if (tab.nb < self.tabs.current_tab_index and tab_refs[state][-1].nb > self.tabs.current_tab_index): continue self.command.win(str(tab.nb)) diff --git a/poezio/core/tabs.py b/poezio/core/tabs.py index 18f0ce49..3adaf478 100644 --- a/poezio/core/tabs.py +++ b/poezio/core/tabs.py @@ -157,15 +157,11 @@ class Tabs: self._current_tab = self._tabs[0] def _inc_cursor(self): - self._current_index += 1 - if self._current_index >= len(self._tabs): - self._current_index = 0 + self._current_index = (self._current_index + 1) % len(self._tabs) self._current_tab = self._tabs[self._current_index] def _dec_cursor(self): - self._current_index -= 1 - if self._current_index < 0: - self._current_index = len(self._tabs) - 1 + self._current_index = (self._current_index - 1) % len(self._tabs) self._current_tab = self._tabs[self._current_index] def _store_previous(self): @@ -212,18 +208,24 @@ class Tabs: self._tab_types[type(tab)].remove(tab) del self._tab_names[tab.name] - self._collect_trailing_gaptabs() - self._update_numbers() - if is_current: - self._restore_previous_tab() + + if gap: + self._collect_trailing_gaptabs() + else: + self._update_numbers() + if tab is self._previous_tab: self._previous_tab = None + if is_current: + self._restore_previous_tab() self._validate_current_index() def _restore_previous_tab(self): if self._previous_tab: if not self.set_current_tab(self._previous_tab): self.set_current_index(0) + else: + self.set_current_index(0) def _validate_current_index(self): if not 0 <= self._current_index < len( @@ -240,6 +242,7 @@ class Tabs: def _update_numbers(self): for i, tab in enumerate(self._tabs): tab.nb = i + self._current_index = self._current_tab.nb # Moving tabs around # |