Commit 78f130a1 authored by mae's avatar mae
Browse files

Fix Backtab behavior to standard Windows behavior

Creator implemented Backtab similar to Eclipse and other editors,
now we do standard windows behavior.
parent d65eaadd
......@@ -3651,19 +3651,7 @@ void BaseTextEditor::indentOrUnindent(bool doIndent)
QTextDocument *doc = document();
if (!cursor.hasSelection() && doIndent) {
// Insert tab if there is no selection and indent is requested
QTextBlock block = cursor.block();
QString text = block.text();
int indentPosition = (cursor.position() - block.position());;
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, block));
} else {
if (cursor.hasSelection()) {
// Indent or unindent the selected lines
int anchor = cursor.anchor();
int start = qMin(anchor, pos);
......@@ -3684,6 +3672,18 @@ void BaseTextEditor::indentOrUnindent(bool doIndent)
cursor.setPosition(block.position() + indentPosition, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
}
} else {
// Indent or unindent at cursor position
QTextBlock block = cursor.block();
QString text = block.text();
int indentPosition = cursor.positionInBlock();
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, block));
}
cursor.endEditBlock();
......
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