diff --git a/qutebrowser/completion/completiondelegate.py b/qutebrowser/completion/completiondelegate.py index d88c86c19..03caa5158 100644 --- a/qutebrowser/completion/completiondelegate.py +++ b/qutebrowser/completion/completiondelegate.py @@ -22,7 +22,9 @@ We use this to be able to highlight parts of the text. """ +import re import html + from PyQt5.QtWidgets import QStyle, QStyleOptionViewItem, QStyledItemDelegate from PyQt5.QtCore import QRectF, QSize, Qt from PyQt5.QtGui import (QIcon, QPalette, QTextDocument, QTextOption, @@ -195,9 +197,9 @@ class CompletionItemDelegate(QStyledItemDelegate): if index.parent().isValid(): pattern = index.model().pattern if index.column() == 0 and pattern: - text = self._opt.text.replace( - pattern, - '{}'.format(pattern)) + repl = r'\g<0>' + text = re.sub(re.escape(pattern), repl, self._opt.text, + flags=re.IGNORECASE) self._doc.setHtml(text) else: self._doc.setPlainText(self._opt.text)