summaryrefslogtreecommitdiff
path: root/alot/buffers
diff options
context:
space:
mode:
Diffstat (limited to 'alot/buffers')
-rw-r--r--alot/buffers/thread.py22
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"""