summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-05-05 22:26:04 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2012-05-05 22:26:04 +0100
commita7a3fd5599eedc25f70ea75e0140455d989a98d6 (patch)
treec84a7c2e57dc8639f890a204dd16e9d6ff4cce2d /alot
parent2cb5996bc6cea048b981ea26bdfe90d8ae7dcd60 (diff)
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.
Diffstat (limited to 'alot')
-rw-r--r--alot/buffers.py4
1 files changed, 3 insertions, 1 deletions
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):