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.
This commit is contained in:
parent
d62cb58f7d
commit
1e9a70855d
@ -203,9 +203,9 @@ class CompletionItemDelegate(QStyledItemDelegate):
|
|||||||
columns_to_filter = index.model().columns_to_filter(index)
|
columns_to_filter = index.model().columns_to_filter(index)
|
||||||
if index.column() in columns_to_filter and pattern:
|
if index.column() in columns_to_filter and pattern:
|
||||||
repl = r'<span class="highlight">\g<0></span>'
|
repl = r'<span class="highlight">\g<0></span>'
|
||||||
text = re.sub(re.escape(pattern).replace(r'\ ', r'|'),
|
pat = html.escape(re.escape(pattern)).replace(r'\ ', r'|')
|
||||||
repl, html.escape(self._opt.text),
|
txt = html.escape(self._opt.text)
|
||||||
flags=re.IGNORECASE)
|
text = re.sub(pat, repl, txt, flags=re.IGNORECASE)
|
||||||
self._doc.setHtml(text)
|
self._doc.setHtml(text)
|
||||||
else:
|
else:
|
||||||
self._doc.setPlainText(self._opt.text)
|
self._doc.setPlainText(self._opt.text)
|
||||||
|
Loading…
Reference in New Issue
Block a user