TextEditor: Fixed indentation in block selection mode

Made indentation work for block selection mode the same way it does in default mode:

1. delete text if any selected
2. indent block if no text selected
3. indent last line if cursor in first column (QTCREATORBUG-12697)

Task-number: QTCREATORBUG-12697
Change-Id: I1f6b218b389f3fdc5232ec02857aa76f5ccbaaf0
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
Vladyslav Gapchych
2015-07-16 15:56:25 +02:00
committed by David Schulz
parent c5bca90b0e
commit aab3b0fc66
5 changed files with 110 additions and 55 deletions

View File

@@ -198,12 +198,13 @@ int TabSettings::columnAt(const QString &text, int position) const
return column;
}
int TabSettings::positionAtColumn(const QString &text, int column, int *offset) const
int TabSettings::positionAtColumn(const QString &text, int column, int *offset, bool allowOverstep) const
{
int col = 0;
int i = 0;
while (i < text.size() && col < column) {
if (text.at(i) == QLatin1Char('\t'))
int textSize = text.size();
while ((i < textSize || allowOverstep) && col < column) {
if (i < textSize && text.at(i) == QLatin1Char('\t'))
col = col - (col % m_tabSize) + m_tabSize;
else
++col;
@@ -228,6 +229,8 @@ int TabSettings::columnCountForText(const QString &text, int startColumn) const
int TabSettings::spacesLeftFromPosition(const QString &text, int position)
{
if (position >= text.size())
return 0;
int i = position;
while (i > 0) {
if (!text.at(i-1).isSpace())