Commit 2d9996c7 authored by Roopesh Chander's avatar Roopesh Chander Committed by Thorbjørn Lindeijer
Browse files

Pass the current block in all applicable invocations of TabSettings::indentationString()



Merge-request: 1766
Reviewed-by: default avatarThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
parent 764245ee
......@@ -3656,11 +3656,10 @@ void BaseTextEditor::indentOrUnindent(bool doIndent)
int spaces = tabSettings.spacesLeftFromPosition(text, indentPosition);
int startColumn = tabSettings.columnAt(text, indentPosition - spaces);
int targetColumn = tabSettings.indentedColumn(tabSettings.columnAt(text, indentPosition), doIndent);
cursor.setPosition(block.position() + indentPosition);
cursor.setPosition(block.position() + indentPosition - spaces, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
cursor.insertText(tabSettings.indentationString(startColumn, targetColumn));
cursor.insertText(tabSettings.indentationString(startColumn, targetColumn, block));
} else {
// Indent or unindent the selected lines
int anchor = cursor.anchor();
......@@ -3677,7 +3676,7 @@ void BaseTextEditor::indentOrUnindent(bool doIndent)
indentPosition = tabSettings.firstNonSpace(text);
int targetColumn = tabSettings.indentedColumn(tabSettings.columnAt(text, indentPosition), doIndent);
cursor.setPosition(block.position() + indentPosition);
cursor.insertText(tabSettings.indentationString(0, targetColumn));
cursor.insertText(tabSettings.indentationString(0, targetColumn, block));
cursor.setPosition(block.position());
cursor.setPosition(block.position() + indentPosition, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
......@@ -5006,7 +5005,7 @@ void BaseTextEditor::rewrapParagraph()
QString spacing;
if (commonPrefix.isEmpty()) {
spacing = tabSettings().indentationString(0, indentLevel);
spacing = tabSettings().indentationString(0, indentLevel, textCursor().block());
} else {
spacing = commonPrefix;
indentLevel = commonPrefix.length();
......
......@@ -62,7 +62,7 @@ struct TEXTEDITOR_EXPORT TabSettings
int columnAt(const QString &text, int position) const;
int spacesLeftFromPosition(const QString &text, int position) const;
int indentedColumn(int column, bool doIndent = true) const;
QString indentationString(int startColumn, int targetColumn, const QTextBlock& block = QTextBlock()) const;
QString indentationString(int startColumn, int targetColumn, const QTextBlock& currentBlock = QTextBlock()) const;
QString indentationString(const QString &text) const;
int indentationColumn(const QString &text) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment