Filter hints using a multi-word matching
(addresses https://github.com/The-Compiler/qutebrowser/issues/674#issuecomment-165101219 )
This commit is contained in:
parent
d3eec49b6e
commit
e4d5b550a3
@ -724,6 +724,16 @@ class HintManager(QObject):
|
|||||||
keyparser = keyparsers[usertypes.KeyMode.hint]
|
keyparser = keyparsers[usertypes.KeyMode.hint]
|
||||||
keyparser.update_bindings(strings, preserve_filter=True)
|
keyparser.update_bindings(strings, preserve_filter=True)
|
||||||
|
|
||||||
|
def _filter_matches(self, filterstr, elemstr):
|
||||||
|
"""Returns True if `filterstr` matches `elemstr`."""
|
||||||
|
# Empty string and None always match
|
||||||
|
if not filterstr:
|
||||||
|
return True
|
||||||
|
filterstr = filterstr.casefold()
|
||||||
|
elemstr = elemstr.casefold()
|
||||||
|
# Do multi-word matching
|
||||||
|
return all(word in elemstr for word in filterstr.split())
|
||||||
|
|
||||||
def follow_prevnext(self, frame, baseurl, prev=False, tab=False,
|
def follow_prevnext(self, frame, baseurl, prev=False, tab=False,
|
||||||
background=False, window=False):
|
background=False, window=False):
|
||||||
"""Click a "previous"/"next" element on the page.
|
"""Click a "previous"/"next" element on the page.
|
||||||
@ -901,8 +911,7 @@ class HintManager(QObject):
|
|||||||
|
|
||||||
for elems in self._context.all_elems:
|
for elems in self._context.all_elems:
|
||||||
try:
|
try:
|
||||||
if (filterstr is None or
|
if self._filter_matches(filterstr, str(elems.elem)):
|
||||||
filterstr.casefold() in str(elems.elem).casefold()):
|
|
||||||
if self._is_hidden(elems.label):
|
if self._is_hidden(elems.label):
|
||||||
# hidden element which matches again -> show it
|
# hidden element which matches again -> show it
|
||||||
self._show_elem(elems.label)
|
self._show_elem(elems.label)
|
||||||
|
Loading…
Reference in New Issue
Block a user