diff --git a/src/plugins/find/basetextfind.cpp b/src/plugins/find/basetextfind.cpp index 1a9cbe3f5c44e805da5e2b832b0e9d6fcd374017..d2ddfc0441856d79ad392f65804de325ac84c5b2 100644 --- a/src/plugins/find/basetextfind.cpp +++ b/src/plugins/find/basetextfind.cpp @@ -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; diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 178e857350ca53905807555b7fd8ecc828e8527f..2f43968ec85c9fe9fc76dca2f653fe551483cc67 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -2471,7 +2471,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;