forked from qt-creator/qt-creator
fakevim: Fix for searches with an empty match
If searching (in "/" command mode) with regular expression "\\b" or ".{0}" the search takes infinitely long. This fix highlights one character to the right of empty match (behaviour is similar in Vim). Change-Id: I5113177cf6af0ef0197e14f0165227e7538a3d1d Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -3920,11 +3920,6 @@ static QRegExp vimPatternToQtPattern(QString needle, QTextDocument::FindFlags *f
|
||||
// FIXME: Rough mapping of a common case.
|
||||
if (needle.startsWith(_("\\<")) && needle.endsWith(_("\\>")))
|
||||
(*flags) |= QTextDocument::FindWholeWords;
|
||||
// Half-hearted attempt at removing pitfalls.
|
||||
if (needle.startsWith(_(".*")))
|
||||
needle = needle.mid(2);
|
||||
if (needle.endsWith(_(".*")))
|
||||
needle = needle.left(needle.size() - 2);
|
||||
needle.remove(_("\\<")); // start of word
|
||||
needle.remove(_("\\>")); // end of word
|
||||
|
||||
@@ -4046,6 +4041,8 @@ void FakeVimHandler::Private::highlightMatches(const QString &needle)
|
||||
tc = tc.document()->find(needleExp, tc.position(), flags);
|
||||
if (tc.isNull())
|
||||
break;
|
||||
if (!tc.hasSelection())
|
||||
tc.movePosition(Right, KeepAnchor, 1);
|
||||
QTextEdit::ExtraSelection sel;
|
||||
sel.cursor = tc;
|
||||
sel.format = tc.blockCharFormat();
|
||||
|
Reference in New Issue
Block a user