TextEditor: Indent line when comment marker is not in the first column

Change-Id: I02713f1151264411451c5d9b476847e451ccef05
Fixes: QTCREATORBUG-21852
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
David Schulz
2019-04-25 12:44:50 +02:00
parent a1c67da0a2
commit 132d813343

View File

@@ -2011,19 +2011,22 @@ void TextEditorWidgetPrivate::moveLineUpDown(bool up)
bool shouldReindent = true;
if (m_commentDefinition.isValid()) {
QString trimmedText(text.trimmed());
if (m_commentDefinition.hasSingleLineStyle()) {
if (trimmedText.startsWith(m_commentDefinition.singleLine))
shouldReindent = false;
}
if (shouldReindent && m_commentDefinition.hasMultiLineStyle()) {
if (m_commentDefinition.hasMultiLineStyle()) {
// Don't have any single line comments; try multi line.
if (trimmedText.startsWith(m_commentDefinition.multiLineStart)
&& trimmedText.endsWith(m_commentDefinition.multiLineEnd)) {
if (text.startsWith(m_commentDefinition.multiLineStart)
&& text.endsWith(m_commentDefinition.multiLineEnd)) {
shouldReindent = false;
}
}
if (shouldReindent && m_commentDefinition.hasSingleLineStyle()) {
shouldReindent = false;
QTextBlock block = move.block();
while (block.isValid() && block.position() < end) {
if (!block.text().startsWith(m_commentDefinition.singleLine))
shouldReindent = true;
block = block.next();
}
}
}
if (shouldReindent) {