diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-07-05 11:44:32 -0700 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2018-07-24 22:11:38 +0100 |
commit | 2842cc9e334c5339ca9e2258a997a7e16901718d (patch) | |
tree | dd562743d75a23c6964371c8c08a1ab572d35506 /alot/widgets/search.py | |
parent | d76de213d04807a064be1f937d1b325e6bea945d (diff) |
widgets/search: Don't try to sort an iterator
We currently call dict_keys.sort(), which doesn't work because it
doesn't exist. The whole function is kinda strange anyway, since there's
a lot of work done in general that only applies in once case.
Diffstat (limited to 'alot/widgets/search.py')
-rw-r--r-- | alot/widgets/search.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/alot/widgets/search.py b/alot/widgets/search.py index d8fffec9..07fa186d 100644 --- a/alot/widgets/search.py +++ b/alot/widgets/search.py @@ -193,13 +193,12 @@ def build_text_part(name, thread, struct, minw, maxw, align): content = pad(subjectstring) elif name == 'content': if thread: - msgs = thread.get_messages().keys() + msgs = sorted(thread.get_messages().keys(), key=lambda msg: + msg.get_date(), reverse=True) + lastcontent = ' '.join(m.get_text_content() for m in msgs) + content = pad(lastcontent.replace('\n', ' ').strip()) else: - msgs = [] - # sort the most recent messages first - msgs.sort(key=lambda msg: msg.get_date(), reverse=True) - lastcontent = ' '.join([m.get_text_content() for m in msgs]) - content = pad(lastcontent.replace('\n', ' ').strip()) + content = pad('') # define width and part_w in case the above produced a content string if content: |