forked from qt-creator/qt-creator
C++: Avoid superfluous * in comment continuation
This fixes the issue pointed below and the general case int which superfluous asterisks are generated. Task-number: QTCREATORBUG-6823 Change-Id: I1c8659fb5734609d90cfad052804943b8b99d5df Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
@@ -2332,26 +2332,36 @@ bool CPPEditorWidget::handleDocumentationComment(QKeyEvent *e)
|
||||
if (!m_commentsSettings.m_leadingAsterisks)
|
||||
return false;
|
||||
|
||||
const QString &text = cursor.block().text();
|
||||
const int length = text.length();
|
||||
// We continue the comment if the cursor is after a comment's line asterisk and if
|
||||
// there's no asterisk immediately after the cursor (that would already be considered
|
||||
// a leading asterisk).
|
||||
int offset = 0;
|
||||
for (; offset < length; ++offset) {
|
||||
const QChar ¤t = text.at(offset);
|
||||
if (!current.isSpace())
|
||||
const int blockPos = cursor.positionInBlock();
|
||||
const QString &text = cursor.block().text();
|
||||
for (; offset < blockPos; ++offset) {
|
||||
if (!text.at(offset).isSpace())
|
||||
break;
|
||||
}
|
||||
if (offset < length
|
||||
|
||||
if (offset < blockPos
|
||||
&& (text.at(offset) == QLatin1Char('*')
|
||||
|| (offset < length - 1
|
||||
|| (offset < blockPos - 1
|
||||
&& text.at(offset) == QLatin1Char('/')
|
||||
&& text.at(offset + 1) == QLatin1Char('*')))) {
|
||||
int followinPos = blockPos;
|
||||
for (; followinPos < text.length(); ++followinPos) {
|
||||
if (!text.at(followinPos).isSpace())
|
||||
break;
|
||||
}
|
||||
if (followinPos == text.length()
|
||||
|| text.at(followinPos) != QLatin1Char('*')) {
|
||||
QString newLine(QLatin1Char('\n'));
|
||||
newLine.append(QString(offset, QLatin1Char(' ')));
|
||||
if (text.at(offset) == QLatin1Char('/')) {
|
||||
newLine.append(QLatin1String(" *"));
|
||||
} else {
|
||||
int start = offset;
|
||||
while (offset < length && text.at(offset) == QLatin1Char('*'))
|
||||
while (offset < blockPos && text.at(offset) == QLatin1Char('*'))
|
||||
++offset;
|
||||
newLine.append(QString(offset - start, QLatin1Char('*')));
|
||||
}
|
||||
@@ -2360,6 +2370,7 @@ bool CPPEditorWidget::handleDocumentationComment(QKeyEvent *e)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user