diff options
Diffstat (limited to 'alot/buffers/search.py')
-rw-r--r-- | alot/buffers/search.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/alot/buffers/search.py b/alot/buffers/search.py index bf758c95..20c0ae47 100644 --- a/alot/buffers/search.py +++ b/alot/buffers/search.py @@ -5,9 +5,9 @@ import asyncio import urwid -from notmuch2 import NotmuchError from .buffer import Buffer +from ..db.errors import QueryError from ..db.sort import NAME as SORT_NAME from ..settings.const import settings from ..widgets.search import ThreadlineWidget @@ -163,20 +163,24 @@ class SearchBuffer(Buffer): self._result_count = None self._thread_count = None + threads = self.dbman.get_threads(self.querystring, self.sort_order, + exclude_tags) + threadlist = IterWalker(threads, self.dbman) + + # check that the query is well-formed try: - threads = self.dbman.get_threads(self.querystring, self.sort_order, - exclude_tags) - except NotmuchError: + threadlist[0] + except IndexError: + # empty result list, no problem + pass + except QueryError: self.ui.notify('malformed query string: %s' % self.querystring, 'error') - self.listbox = urwid.ListBox([]) - self.body = self.listbox - return - - self.threadlist = IterWalker(threads, self.dbman) + threadlist = [] - self.listbox = urwid.ListBox(self.threadlist) - self.body = self.listbox + self.threadlist = threadlist + self.listbox = urwid.ListBox(self.threadlist) + self.body = self.listbox def get_selected_threadline(self): """ |