Refactor block selection

Block selection was "broken" when using tabs, or rather
incomplete: It treated tabs as normal characters, which
has shown to be unexpected by people using tabs in code.

The new implementation has a vastly improved find scope
as well. In addition, creating a blog selection with
mouse or keyboard feels a lot more solid now, as the
actual selection is detached from possible valid cursor
positions.

Task-number: QTCREATORBUG-1541
This commit is contained in:
mae
2010-08-05 15:01:20 +02:00
parent 9b338fbbe4
commit 29b073e92e
10 changed files with 510 additions and 225 deletions

View File

@@ -226,6 +226,22 @@ int TabSettings::columnAt(const QString &text, int position) const
return column;
}
int TabSettings::positionAtColumn(const QString &text, int column, int *offset) const
{
int col = 0;
int i = 0;
while (i < text.size() && col < column) {
if (text.at(i) == QLatin1Char('\t'))
col = col - (col % m_tabSize) + m_tabSize;
else
++col;
++i;
}
if (offset)
*offset = column - col;
return i;
}
int TabSettings::spacesLeftFromPosition(const QString &text, int position) const
{
int i = position;