From 1e9a70855d2b371cbdd4265725434a876142efc7 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Sun, 21 Jan 2018 07:42:39 -0500 Subject: [PATCH] Show '&' properly in completion widget. When highlighting the matched part of the text, we need to html-escape the pattern used to find the matching text so it will replace terms that have been escaped in the text, like &. Resolves #3508. --- qutebrowser/completion/completiondelegate.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qutebrowser/completion/completiondelegate.py b/qutebrowser/completion/completiondelegate.py index b4f9c5a33..ab98eccef 100644 --- a/qutebrowser/completion/completiondelegate.py +++ b/qutebrowser/completion/completiondelegate.py @@ -203,9 +203,9 @@ class CompletionItemDelegate(QStyledItemDelegate): columns_to_filter = index.model().columns_to_filter(index) if index.column() in columns_to_filter and pattern: repl = r'\g<0>' - text = re.sub(re.escape(pattern).replace(r'\ ', r'|'), - repl, html.escape(self._opt.text), - flags=re.IGNORECASE) + pat = html.escape(re.escape(pattern)).replace(r'\ ', r'|') + txt = html.escape(self._opt.text) + text = re.sub(pat, repl, txt, flags=re.IGNORECASE) self._doc.setHtml(text) else: self._doc.setPlainText(self._opt.text)