forked from qt-creator/qt-creator
Fix critical vertical block selection issue
Vertical block selections could be painted where there was no selection, or they could jump randomly to columns futher right. Reviewed-by: dt
This commit is contained in:
@@ -325,10 +325,11 @@ void BaseTextFind::defineFindScope()
|
||||
verticalBlockSelection = m_plaineditor->property("verticalBlockSelection").toInt();
|
||||
|
||||
if (verticalBlockSelection) {
|
||||
int findScopeFromColumn = qMin(m_findScopeStart.positionInBlock()+1,
|
||||
QTextCursor findScopeVisualStart(document()->docHandle(), cursor.selectionStart());
|
||||
int findScopeFromColumn = qMin(findScopeVisualStart.positionInBlock(),
|
||||
m_findScopeEnd.positionInBlock());
|
||||
int findScopeToColumn = findScopeFromColumn + verticalBlockSelection;
|
||||
m_findScopeStart.setPosition(m_findScopeStart.block().position() + findScopeFromColumn - 1);
|
||||
m_findScopeStart.setPosition(findScopeVisualStart.block().position() + findScopeFromColumn - 1);
|
||||
m_findScopeEnd.setPosition(m_findScopeEnd.block().position()
|
||||
+ qMin(m_findScopeEnd.block().length()-1, findScopeToColumn));
|
||||
m_findScopeVerticalBlockSelection = verticalBlockSelection;
|
||||
|
||||
@@ -2466,7 +2466,7 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
|
||||
const QAbstractTextDocumentLayout::Selection &range = context.selections.at(i);
|
||||
const int selStart = range.cursor.selectionStart() - blpos;
|
||||
const int selEnd = range.cursor.selectionEnd() - blpos;
|
||||
if (selStart <= bllen && selEnd >= 0
|
||||
if (selStart < bllen && selEnd >= 0
|
||||
&& selEnd >= selStart) {
|
||||
QTextLayout::FormatRange o;
|
||||
o.start = selStart;
|
||||
|
||||
Reference in New Issue
Block a user