TextEditor: fix indent length calculation for rewrapParagraph

Fixes: QTCREATORBUG-27602
Change-Id: I43650be75807c9954eeabca4dbe6749de493f523
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2022-06-07 13:49:39 +02:00
parent 33167f7f50
commit b4b779d641

View File

@@ -6975,6 +6975,7 @@ void TextEditorWidget::rewrapParagraph()
{ {
const int paragraphWidth = marginSettings().m_marginColumn; const int paragraphWidth = marginSettings().m_marginColumn;
const QRegularExpression anyLettersOrNumbers("\\w"); const QRegularExpression anyLettersOrNumbers("\\w");
const TabSettings ts = d->m_document->tabSettings();
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
cursor.beginEditBlock(); cursor.beginEditBlock();
@@ -6996,7 +6997,7 @@ void TextEditorWidget::rewrapParagraph()
// Find indent level of current block. // Find indent level of current block.
const QString text = cursor.block().text(); const QString text = cursor.block().text();
int indentLevel = textDocument()->tabSettings().indentationColumn(text); int indentLevel = ts.indentationColumn(text);
// If there is a common prefix, it should be kept and expanded to all lines. // If there is a common prefix, it should be kept and expanded to all lines.
// this allows nice reflowing of doxygen style comments. // this allows nice reflowing of doxygen style comments.
@@ -7033,11 +7034,10 @@ void TextEditorWidget::rewrapParagraph()
QString spacing; QString spacing;
if (commonPrefix.isEmpty()) { if (commonPrefix.isEmpty()) {
spacing = d->m_document->tabSettings().indentationString( spacing = ts.indentationString(0, indentLevel, 0, textCursor().block());
0, indentLevel, 0, textCursor().block());
} else { } else {
spacing = commonPrefix; spacing = commonPrefix;
indentLevel = commonPrefix.length(); indentLevel = ts.columnCountForText(spacing);
} }
int currentLength = indentLevel; int currentLength = indentLevel;