forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user