diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index e6149b9bacd1cc7e68837b0e0203156fc4518b0f..1e7a3b891a729953f9f12e856b52ffdac3839c19 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -2381,7 +2381,10 @@ bool CPPEditorWidget::handleDocumentationComment(QKeyEvent *e) if (followinPos == text.length() || text.at(followinPos) != QLatin1Char('*')) { QString newLine(QLatin1Char('\n')); - newLine.append(QString(offset, QLatin1Char(' '))); + QTextCursor c(cursor); + c.movePosition(QTextCursor::StartOfBlock); + c.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, offset); + newLine.append(c.selectedText()); if (text.at(offset) == QLatin1Char('/')) { newLine.append(QLatin1String(" *")); } else { diff --git a/src/plugins/cpptools/doxygengenerator.cpp b/src/plugins/cpptools/doxygengenerator.cpp index fe48422344e0d1d4ee8dd514792bc7a7daafbe3d..5737192bf10623edda9a428a91d66d9e003980b2 100644 --- a/src/plugins/cpptools/doxygengenerator.cpp +++ b/src/plugins/cpptools/doxygengenerator.cpp @@ -56,7 +56,6 @@ DoxygenGenerator::DoxygenGenerator() , m_generateBrief(true) , m_startComment(true) , m_style(QtStyle) - , m_commentOffset(0) {} void DoxygenGenerator::setStyle(DocumentationStyle style) @@ -308,16 +307,11 @@ void DoxygenGenerator::assignCommentOffset(QTextCursor cursor) cursor.setPosition(cursor.anchor()); } - m_commentOffset = cursor.positionInBlock(); + cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); + m_commentOffset = cursor.selectedText(); } QString DoxygenGenerator::offsetString() const { - // Note: Currently we don't indent comments, but simply preserve them in the original - // relative positions. What we do here is just to make sure that such positions are correct, - // although they might still be wrong from an indentation point of view (for instance, - // using spaces instead of tabs). Therefore, the content generated should still have - // the indentation strings fixed. - - return QString(m_commentOffset, QLatin1Char(' ')); + return m_commentOffset; } diff --git a/src/plugins/cpptools/doxygengenerator.h b/src/plugins/cpptools/doxygengenerator.h index a9d1cfbfa4db919fec498d657345e5763e9cc758..77b6db8504ef5d0d9af17fe5da9a9084fe46fe97 100644 --- a/src/plugins/cpptools/doxygengenerator.h +++ b/src/plugins/cpptools/doxygengenerator.h @@ -95,7 +95,7 @@ private: bool m_startComment; DocumentationStyle m_style; CPlusPlus::Overview m_printer; - int m_commentOffset; + QString m_commentOffset; }; } // CppTools