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()