summaryrefslogtreecommitdiff
path: root/alot/buffers
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-01-31 10:32:36 +0100
committerAnton Khirnov <anton@khirnov.net>2021-01-31 10:32:36 +0100
commit999de45bad934654a7b1f1d874d08fbe0922660f (patch)
tree2ce04fe7c0212d398a3c5c0dc6405acaf49e87e2 /alot/buffers
parent50bcdf5aedb336e86278f02b89ac2725f3ea7940 (diff)
buffers/search: fix handling malformed queries
Diffstat (limited to 'alot/buffers')
-rw-r--r--alot/buffers/search.py26
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):
"""