FakeVim: Fix Qt6 build

Amends f626e27370

Change-Id: Id4681dc771a132bc6143b7e1f0b566a3930706e2
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Leander Schulten
2021-02-04 13:03:18 +01:00
parent df8aec0c19
commit 4ae93a9d27

View File

@@ -7411,7 +7411,8 @@ void FakeVimHandler::Private::toggleComment(const Range &range)
QStringList lines = text.split('\n'); QStringList lines = text.split('\n');
const QRegExp checkForComment("^\\s*" + QRegExp::escape(commentString)); const QRegularExpression checkForComment("^\\s*"
+ QRegularExpression::escape(commentString));
const bool firstLineIsComment const bool firstLineIsComment
= !lines.empty() && lines.front().contains(checkForComment); = !lines.empty() && lines.front().contains(checkForComment);
@@ -7419,13 +7420,13 @@ void FakeVimHandler::Private::toggleComment(const Range &range)
for (auto& line : lines) { for (auto& line : lines) {
if (!line.isEmpty()) { if (!line.isEmpty()) {
if (firstLineIsComment) { if (firstLineIsComment) {
const bool hasSpaceAfterCommentString const bool hasSpaceAfterCommentString = line.contains(
= line.contains(QRegExp(checkForComment.pattern() + "\\s")); QRegularExpression(checkForComment.pattern() + "\\s"));
const int sizeToReplace = hasSpaceAfterCommentString ? commentString.size() + 1 const int sizeToReplace = hasSpaceAfterCommentString ? commentString.size() + 1
: commentString.size(); : commentString.size();
line.replace(line.indexOf(commentString), sizeToReplace, ""); line.replace(line.indexOf(commentString), sizeToReplace, "");
} else { } else {
const int indexOfFirstNonSpace = line.indexOf(QRegExp("[^\\s]")); const int indexOfFirstNonSpace = line.indexOf(QRegularExpression("[^\\s]"));
line = line.left(indexOfFirstNonSpace) + commentString + " " + line.right(line.size() - indexOfFirstNonSpace); line = line.left(indexOfFirstNonSpace) + commentString + " " + line.right(line.size() - indexOfFirstNonSpace);
} }
} }