diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-05-04 13:32:08 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-05-05 11:24:33 +0200 |
commit | 85f50af0ebde0d07ba47bea1bcf916d692567252 (patch) | |
tree | 1da78faa48d7ad35738d02ea8f1c29c97882a0f8 /alot/buffers | |
parent | 75c7a2f9dcc1fd36f37b93c512725528aafef457 (diff) |
buffers/thread: fix focus_next/prev_sibling
Diffstat (limited to 'alot/buffers')
-rw-r--r-- | alot/buffers/thread.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/alot/buffers/thread.py b/alot/buffers/thread.py index 052ed98d..b2d5f711 100644 --- a/alot/buffers/thread.py +++ b/alot/buffers/thread.py @@ -198,23 +198,23 @@ class ThreadBuffer(Buffer): new_focus = self.thread.message_list.index(msg.replies[-1]) self.set_focus(new_focus) + def _focus_sibling(self, offset): + msg = self.get_selected_message() + siblings = msg.parent.replies if msg.depth > 0 else self.thread.toplevel_messages + self_idx = siblings.index(msg) + + new_idx = self_idx + offset + if new_idx >= 0 and new_idx < len(siblings): + self.set_focus(self.thread.message_list.index(siblings[new_idx])) + def focus_next_sibling(self): """focus next sibling of currently focussed message in thread tree""" - pos_next = self.get_selected_message_position() + 1 - depth = self.get_selected_message().depth - if (pos_next < self.thread.total_messages and - self.thread.message_list[pos_next].depth == depth): - self.set_focus(pos_next) - + self._focus_sibling(1) def focus_prev_sibling(self): """ focus previous sibling of currently focussed message in thread tree """ - pos_next = self.get_selected_message_position() - 1 - depth = self.get_selected_message().depth - if (pos_next < self.thread.total_messages and - self.thread.message_list[pos_next].depth == depth): - self.set_focus(pos_next) + self._focus_sibling(-1) def focus_next(self): """focus next message in depth first order""" |