From b4b779d6410f0d24a6fb6d760dae68eeb97d123c Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 7 Jun 2022 13:49:39 +0200 Subject: [PATCH] TextEditor: fix indent length calculation for rewrapParagraph Fixes: QTCREATORBUG-27602 Change-Id: I43650be75807c9954eeabca4dbe6749de493f523 Reviewed-by: Eike Ziller --- src/plugins/texteditor/texteditor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index f5b0b8afa88..eb33c6de6a3 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -6975,6 +6975,7 @@ void TextEditorWidget::rewrapParagraph() { const int paragraphWidth = marginSettings().m_marginColumn; const QRegularExpression anyLettersOrNumbers("\\w"); + const TabSettings ts = d->m_document->tabSettings(); QTextCursor cursor = textCursor(); cursor.beginEditBlock(); @@ -6996,7 +6997,7 @@ void TextEditorWidget::rewrapParagraph() // Find indent level of current block. 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. // this allows nice reflowing of doxygen style comments. @@ -7033,11 +7034,10 @@ void TextEditorWidget::rewrapParagraph() QString spacing; if (commonPrefix.isEmpty()) { - spacing = d->m_document->tabSettings().indentationString( - 0, indentLevel, 0, textCursor().block()); + spacing = ts.indentationString(0, indentLevel, 0, textCursor().block()); } else { spacing = commonPrefix; - indentLevel = commonPrefix.length(); + indentLevel = ts.columnCountForText(spacing); } int currentLength = indentLevel;