From 3a5ae32630093584919645d62ee4252d935e7c99 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Tue, 21 Aug 2012 21:46:35 +0100 Subject: 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 --- alot/walker.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'alot/walker.py') 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): -- cgit v1.2.3