summaryrefslogtreecommitdiff
path: root/alot/walker.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-08-21 21:46:35 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2012-08-27 21:23:48 +0100
commit3a5ae32630093584919645d62ee4252d935e7c99 (patch)
tree501db7ae546091ceecfdafbd34feef279bbbae44 /alot/walker.py
parentb634e265e77466be67f743ea28d3b05236291807 (diff)
fix focus placement after tag command
This makes sure that after a tagging operation, if the thread doesn't match the current search any more and thus gets removed from the list, the focus is shifted more naturally: If there are remaining entries below the removed one, focus the next lower. Otherwise (we are at the end of the list) focus the new last entry. Previously, if the last entry was removed, the focus shifted to the beginning of the list. closes #176
Diffstat (limited to 'alot/walker.py')
-rw-r--r--alot/walker.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/alot/walker.py b/alot/walker.py
index a9306bb8..d1d0a898 100644
--- a/alot/walker.py
+++ b/alot/walker.py
@@ -34,9 +34,13 @@ class PipeWalker(urwid.ListWalker):
return self._get_at_pos(start_from - 1)
def remove(self, obj):
+ next_focus = self.focus % len(self.lines)
+ if self.focus == len(self.lines) - 1 and self.empty:
+ next_focus = self.focus - 1
+
self.lines.remove(obj)
if self.lines:
- self.set_focus(self.focus % len(self.lines))
+ self.set_focus(next_focus)
self._modified()
def _get_at_pos(self, pos):