Skip to content

Commit

Permalink
Always use wrapped set_focus to ensure valign for all movement actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrichar1 authored and pazz committed Jul 7, 2020
1 parent 85858de commit 32b885d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions alot/buffers/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ def set_focus(self, pos):

def focus_first(self):
"""set focus to first message of thread"""
self.body.set_focus(self._nested_tree.root)
self.set_focus(self._nested_tree.root)

def focus_last(self):
self.body.set_focus(next(self._nested_tree.positions(reverse=True)))
self.set_focus(next(self._nested_tree.positions(reverse=True)))

def _sanitize_position(self, pos):
return self._nested_tree._sanitize_position(pos,
Expand All @@ -204,31 +204,31 @@ def focus_parent(self):
newpos = self._tree.parent_position(mid)
if newpos is not None:
newpos = self._sanitize_position((newpos,))
self.body.set_focus(newpos)
self.set_focus(newpos)

def focus_first_reply(self):
"""move focus to first reply to currently focussed message"""
mid = self.get_selected_mid()
newpos = self._tree.first_child_position(mid)
if newpos is not None:
newpos = self._sanitize_position((newpos,))
self.body.set_focus(newpos)
self.set_focus(newpos)

def focus_last_reply(self):
"""move focus to last reply to currently focussed message"""
mid = self.get_selected_mid()
newpos = self._tree.last_child_position(mid)
if newpos is not None:
newpos = self._sanitize_position((newpos,))
self.body.set_focus(newpos)
self.set_focus(newpos)

def focus_next_sibling(self):
"""focus next sibling of currently focussed message in thread tree"""
mid = self.get_selected_mid()
newpos = self._tree.next_sibling_position(mid)
if newpos is not None:
newpos = self._sanitize_position((newpos,))
self.body.set_focus(newpos)
self.set_focus(newpos)

def focus_prev_sibling(self):
"""
Expand All @@ -243,15 +243,15 @@ def focus_prev_sibling(self):
else:
newpos = localroot
if newpos is not None:
self.body.set_focus(newpos)
self.set_focus(newpos)

def focus_next(self):
"""focus next message in depth first order"""
mid = self.get_selected_mid()
newpos = self._tree.next_position(mid)
if newpos is not None:
newpos = self._sanitize_position((newpos,))
self.body.set_focus(newpos)
self.set_focus(newpos)

def focus_prev(self):
"""focus previous message in depth first order"""
Expand All @@ -264,7 +264,7 @@ def focus_prev(self):
else:
newpos = localroot
if newpos is not None:
self.body.set_focus(newpos)
self.set_focus(newpos)

def focus_property(self, prop, direction):
"""does a walk in the given direction and focuses the
Expand All @@ -275,7 +275,7 @@ def focus_property(self, prop, direction):
MT = self._tree[newpos]
if prop(MT):
newpos = self._sanitize_position((newpos,))
self.body.set_focus(newpos)
self.set_focus(newpos)
break
newpos = direction(newpos)

Expand Down Expand Up @@ -341,7 +341,7 @@ def unfold_matching(self, querystring, focus_first=True):
MT.expand(MT.root)
if first is None:
first = (self._tree.position_of_messagetree(MT), MT.root)
self.body.set_focus(first)
self.set_focus(first)
else:
MT.collapse(MT.root)
self.body.refresh()

0 comments on commit 32b885d

Please sign in to comment.