From a2db85b11ee2767b903941f2691310184fc21a1e Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 24 Aug 2020 14:30:51 +0200 Subject: [PATCH] C++: Fix indentation of doxygen comment continuations Align also after the leading asterisk. Fixes: QTCREATORBUG-11749 Change-Id: Ic054598c80206bf38b74345aed20d88486f57cad Reviewed-by: David Schulz --- .../cppdocumentationcommenthelper.cpp | 4 ++- src/plugins/cppeditor/cppdoxygen_test.cpp | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp index bb656d19002..3c3c8f361ea 100644 --- a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp +++ b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp @@ -235,6 +235,7 @@ bool handleDoxygenContinuation(QTextCursor &cursor, newLine.append(QLatin1String(" * ")); else newLine.append(QLatin1String(" ")); + offset += 3; } else { // If '*' is not within a comment, skip. QTextCursor cursorOnFirstNonWhiteSpace(cursor); @@ -249,8 +250,9 @@ bool handleDoxygenContinuation(QTextCursor &cursor, ++offset; const QChar ch = leadingAsterisks ? QLatin1Char('*') : QLatin1Char(' '); newLine.append(QString(offset - start, ch)); - newLine.append(QLatin1Char(' ')); } + for (; offset < blockPos && currentLine.at(offset) == ' '; ++offset) + newLine.append(QLatin1Char(' ')); cursor.insertText(newLine); return true; } diff --git a/src/plugins/cppeditor/cppdoxygen_test.cpp b/src/plugins/cppeditor/cppdoxygen_test.cpp index 79e4e9f2d91..59aad20d072 100644 --- a/src/plugins/cppeditor/cppdoxygen_test.cpp +++ b/src/plugins/cppeditor/cppdoxygen_test.cpp @@ -309,6 +309,34 @@ void DoxygenTest::testBasic_data() " public: void f();\n" "};\n" ); + + QTest::newRow("continuation_after_text_in_first_line") << _( + "bool preventFolding;\n" + "/*! leading comment|\n" + " */\n" + "int a;\n" + ) << _( + "bool preventFolding;\n" + "/*! leading comment\n" + " * \n" + " */\n" + "int a;\n" + ); + + QTest::newRow("continuation_after_extra_indent") << _( + "bool preventFolding;\n" + "/*! leading comment\n" + " * cont|\n" + " */\n" + "int a;\n" + ) << _( + "bool preventFolding;\n" + "/*! leading comment\n" + " * cont\n" + " * \n" + " */\n" + "int a;\n" + ); } void DoxygenTest::testBasic()