forked from qt-creator/qt-creator
TextEditor: use tabsettings to get indent column
Change-Id: I23c84194633ba5cb485fefb6195fcbb3ad37d95a Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -151,7 +151,6 @@
|
|||||||
implementation matches the MIME type.
|
implementation matches the MIME type.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -6976,7 +6975,6 @@ void TextEditorWidget::rewrapParagraph()
|
|||||||
{
|
{
|
||||||
const int paragraphWidth = marginSettings().m_marginColumn;
|
const int paragraphWidth = marginSettings().m_marginColumn;
|
||||||
const QRegularExpression anyLettersOrNumbers("\\w");
|
const QRegularExpression anyLettersOrNumbers("\\w");
|
||||||
const int tabSize = d->m_document->tabSettings().m_tabSize;
|
|
||||||
|
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
@@ -6997,18 +6995,8 @@ void TextEditorWidget::rewrapParagraph()
|
|||||||
cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor);
|
cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor);
|
||||||
|
|
||||||
// Find indent level of current block.
|
// Find indent level of current block.
|
||||||
|
|
||||||
int indentLevel = 0;
|
|
||||||
const QString text = cursor.block().text();
|
const QString text = cursor.block().text();
|
||||||
|
int indentLevel = textDocument()->tabSettings().indentationColumn(text);
|
||||||
for (const QChar &ch : text) {
|
|
||||||
if (ch == QLatin1Char(' '))
|
|
||||||
indentLevel++;
|
|
||||||
else if (ch == QLatin1Char('\t'))
|
|
||||||
indentLevel += tabSize - (indentLevel % tabSize);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
||||||
|
Reference in New Issue
Block a user