From a7a3fd5599eedc25f70ea75e0140455d989a98d6 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sat, 5 May 2012 22:26:04 +0100 Subject: fix empty bufferlist This fixes an issue with BufferlistBuffer being opened with no other buffers open. This can happen if initial command is compose and the user cancels it. If afterwards a bufferlist was opened, we had an error. --- alot/buffers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'alot/buffers.py') diff --git a/alot/buffers.py b/alot/buffers.py index e4401198..09e85283 100644 --- a/alot/buffers.py +++ b/alot/buffers.py @@ -80,7 +80,9 @@ class BufferlistBuffer(Buffer): num = urwid.Text('%3d:' % self.index_of(b)) lines.append(urwid.Columns([('fixed', 4, num), buf])) self.bufferlist = urwid.ListBox(urwid.SimpleListWalker(lines)) - self.bufferlist.set_focus(focusposition % len(displayedbuffers)) + num_buffers = len(displayedbuffers) + if focusposition is not None and num_buffers > 0: + self.bufferlist.set_focus(focusposition % num_buffers) self.body = self.bufferlist def get_selected_buffer(self): -- cgit v1.2.3