diff options
author | mathieui <mathieui@mathieui.net> | 2018-08-11 22:26:24 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2018-08-11 22:26:24 +0200 |
commit | b6c84cba5b26a1b70513e6befcd835e82a94d719 (patch) | |
tree | c5f205725f4e4a0c6e6a4e60ca5c5df044c0c81f | |
parent | 3c8fb156ad552b3c314ca47c85cbcbd3f977c452 (diff) | |
download | poezio-b6c84cba5b26a1b70513e6befcd835e82a94d719.tar.gz poezio-b6c84cba5b26a1b70513e6befcd835e82a94d719.tar.bz2 poezio-b6c84cba5b26a1b70513e6befcd835e82a94d719.tar.xz poezio-b6c84cba5b26a1b70513e6befcd835e82a94d719.zip |
Fix #3424 (fix receipts)
-rw-r--r-- | poezio/core/tabs.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/poezio/core/tabs.py b/poezio/core/tabs.py index 81ad155d..b8c6d3a7 100644 --- a/poezio/core/tabs.py +++ b/poezio/core/tabs.py @@ -145,7 +145,8 @@ class Tabs: self._tab_types = defaultdict(list) self._tab_names = dict() for tab in self._tabs: - self._tab_types[type(tab)].append(tab) + for cls in _get_tab_types(tab): + self._tab_types[cls].append(tab) self._tab_names[tab.name] = tab self._update_numbers() @@ -203,7 +204,8 @@ class Tabs: else: tab.nb = self._tabs[-1].nb + 1 self._tabs.append(tab) - self._tab_types[type(tab)].append(tab) + for cls in _get_tab_types(tab): + self._tab_types[cls].append(tab) self._tab_names[tab.name] = tab def delete(self, tab: tabs.Tab, gap=False): @@ -218,7 +220,8 @@ class Tabs: is_current = tab is self.current_tab - self._tab_types[type(tab)].remove(tab) + for cls in _get_tab_types(tab): + self._tab_types[cls].remove(tab) del self._tab_names[tab.name] if gap: @@ -338,3 +341,13 @@ class Tabs: result = self._insert_nogaps(old_pos, new_pos) self._update_numbers() return result + + +def _get_tab_types(tab: tabs.Tab) -> List[Type[tabs.Tab]]: + """Return all parent classes of a tab type""" + types = [] + current_cls = tab.__class__ + while current_cls != tabs.Tab: + types.append(current_cls) + current_cls = current_cls.__bases__[0] + return types |