From 7116c7c60f70dd8078743d138bde52f79336ca66 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 5 Nov 2020 15:47:35 +0100 Subject: [PATCH] CppEditor: Fix doxygen continuation ... for the case where the cursor is on the first line of the comment. At this point, we have just found out that no initial skeleton is to be created and that we want to do a continuation instead. Therefore, we need to rewind the cursor position, so handleDoxygenContinuation() will receive the original cursor. Fixes: QTCREATORBUG-20677 Change-Id: I42f1b83df624a9833fe13e1fa01e41c5c6c45334 Reviewed-by: Christian Stenger --- .../cppeditor/cppdocumentationcommenthelper.cpp | 1 + src/plugins/cppeditor/cppdoxygen_test.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp index 7014c57bede..9e61b0c91a6 100644 --- a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp +++ b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp @@ -323,6 +323,7 @@ bool trySplitComment(TextEditor::TextEditorWidget *editorWidget, cursor.endEditBlock(); return true; } + cursor.setPosition(pos); } } } // right after first doxygen comment diff --git a/src/plugins/cppeditor/cppdoxygen_test.cpp b/src/plugins/cppeditor/cppdoxygen_test.cpp index 9fc6f1575c1..9511b6df6e6 100644 --- a/src/plugins/cppeditor/cppdoxygen_test.cpp +++ b/src/plugins/cppeditor/cppdoxygen_test.cpp @@ -81,6 +81,21 @@ void DoxygenTest::testBasic_data() "int a;\n" ); + QTest::newRow("qt_style_cursor_before_existing_comment") << _( + "bool preventFolding;\n" + "/*!|\n" + " * \\brief something\n" + " */\n" + "int a;\n" + ) << _( + "bool preventFolding;\n" + "/*!\n" + " * \n" + " * \\brief something\n" + " */\n" + "int a;\n" + ); + QTest::newRow("qt_style_continuation") << _( "bool preventFolding;\n" "/*!\n"