From 534ba14d5c898d50ffcdfd8539eedf10165f7fd9 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 21 Jul 2018 21:36:46 +0200 Subject: Fix /reorder --- poezio/core/tabs.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'poezio/core') diff --git a/poezio/core/tabs.py b/poezio/core/tabs.py index 3adaf478..91a10497 100644 --- a/poezio/core/tabs.py +++ b/poezio/core/tabs.py @@ -141,20 +141,16 @@ class Tabs: self._tab_names[tab.name] = tab self._update_numbers() - def replace_tabs(self, new_tabs: List[tabs.Tab]): + def replace_tabs(self, new_tabs: List[tabs.Tab]) -> bool: """ Replace the current tab list with another, and rebuild the mappings. """ + if self._current_tab not in new_tabs: + return False self._tabs = new_tabs self._rebuild() - current_tab = self.current_tab - try: - idx = self._tabs.index(current_tab) - self._current_index = idx - except ValueError: - self._current_index = 0 - self._current_tab = self._tabs[0] + return True def _inc_cursor(self): self._current_index = (self._current_index + 1) % len(self._tabs) -- cgit v1.2.3