From 8eae872660c24a5f6e426b0f1a8980f6b5a98fcb Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Wed, 25 Jul 2012 19:38:58 +0200 Subject: [PATCH] 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 --- src/plugins/fakevim/fakevimhandler.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index f8d1e01a6a3..67669701a1e 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -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();