be more conservative when reindenting code: only change the

actual whitespace when the indentation column changes.

Complete whitespace cleanup can still be done either automatically
on save (when configured) or when explicitely called with the
"Clean Whitespace" action from Edit/Advanced.
This commit is contained in:
mae
2009-09-09 16:16:46 +02:00
parent 32229e30b4
commit 16e7f0c16f
4 changed files with 14 additions and 14 deletions

View File

@@ -116,6 +116,12 @@ QString TabSettings::indentationString(const QString &text) const
}
int TabSettings::indentationColumn(const QString &text) const
{
return columnAt(text, firstNonSpace(text));
}
int TabSettings::trailingWhitespaces(const QString &text) const
{
int i = 0;
@@ -231,7 +237,7 @@ void TabSettings::indentLine(QTextBlock block, int newIndent) const
const int oldBlockLength = text.size();
// Quickly check whether indenting is required.
if (oldBlockLength == 0 && newIndent == 0)
if (indentationColumn(text) == newIndent)
return;
const QString indentString = indentationString(0, newIndent);
@@ -240,12 +246,6 @@ void TabSettings::indentLine(QTextBlock block, int newIndent) const
if (oldBlockLength == indentString.length() && text == indentString)
return;
if (oldBlockLength > indentString.length() &&
text.startsWith(indentString) &&
!text.at(indentString.length()).isSpace()) {
return;
}
QTextCursor cursor(block);
cursor.beginEditBlock();
cursor.movePosition(QTextCursor::StartOfBlock);