From 42fff6e27e1d37ecc34f13cc0928560468ed5035 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 25 May 2023 12:46:32 +0200 Subject: [PATCH] CMakePM: Add support for block/endblock functions The block() / endblock() functionatlity has been added to CMake version 3.25. See https: //cmake.org/cmake/help/latest/command/block.html Change-Id: If6458b84c3e30c4d4d8cbd3d3f1c661e8ffa869c Reviewed-by: Alessandro Portale --- src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp | 2 +- src/plugins/cmakeprojectmanager/cmakeindenter.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp b/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp index 6e5b482a70a..1f520a86bf5 100644 --- a/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp @@ -89,7 +89,7 @@ QString CMakeAutoCompleter::insertMatchingQuote(const QTextCursor &cursor, int CMakeAutoCompleter::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor) { const QString line = cursor.block().text().trimmed(); - if (line.contains(QRegularExpression(QStringLiteral("^(endfunction|endmacro|endif|endforeach|endwhile)\\w*\\(")))) + if (line.contains(QRegularExpression(QStringLiteral("^(endfunction|endmacro|endif|endforeach|endwhile|endblock)\\w*\\(")))) tabSettings().indentLine(cursor.block(), tabSettings().indentationColumn(cursor.block().text())); return 0; } diff --git a/src/plugins/cmakeprojectmanager/cmakeindenter.cpp b/src/plugins/cmakeprojectmanager/cmakeindenter.cpp index 68157aea5bf..e3e88212c57 100644 --- a/src/plugins/cmakeprojectmanager/cmakeindenter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeindenter.cpp @@ -52,7 +52,8 @@ static bool lineStartsBlock(const QString &line) lineContainsFunction(line, QStringLiteral("while")) || lineContainsFunction(line, QStringLiteral("if")) || lineContainsFunction(line, QStringLiteral("elseif")) || - lineContainsFunction(line, QStringLiteral("else")); + lineContainsFunction(line, QStringLiteral("else")) || + lineContainsFunction(line, QStringLiteral("block")); } static bool lineEndsBlock(const QString &line) { @@ -62,7 +63,8 @@ static bool lineEndsBlock(const QString &line) lineContainsFunction(line, QStringLiteral("endwhile")) || lineContainsFunction(line, QStringLiteral("endif")) || lineContainsFunction(line, QStringLiteral("elseif")) || - lineContainsFunction(line, QStringLiteral("else")); + lineContainsFunction(line, QStringLiteral("else")) || + lineContainsFunction(line, QStringLiteral("endblock")); } static bool lineIsEmpty(const QString &line) {