Snippets: Track begin of first selection

Since in the snippets overlay the selections are created with
ExpandBegin the interest is mostly in detecting when the first one
moved to the left (for example, when an undo is performed right
after inserting the snippet). However, this tracking doesn't need
to necessarily be associated with that flag.
This commit is contained in:
Leandro Melo
2010-11-29 17:25:01 +01:00
parent b87861f9b4
commit fdbb34adb8
3 changed files with 20 additions and 7 deletions

View File

@@ -670,10 +670,7 @@ void BaseTextEditor::editorContentsChange(int position, int charsRemoved, int ch
if (d->m_snippetOverlay->isVisible()) {
QTextCursor cursor = textCursor();
cursor.setPosition(position);
if (!d->m_snippetOverlay->hasCursorInSelection(cursor)) {
d->m_snippetOverlay->hide();
d->m_snippetOverlay->clear();
}
d->snippetCheckCursor(cursor);
}
if (doc->isRedoAvailable())
@@ -2455,7 +2452,8 @@ bool BaseTextEditorPrivate::snippetCheckCursor(const QTextCursor &cursor)
QTextCursor end = cursor;
end.setPosition(cursor.selectionEnd());
if (!m_snippetOverlay->hasCursorInSelection(start)
|| !m_snippetOverlay->hasCursorInSelection(end)) {
|| !m_snippetOverlay->hasCursorInSelection(end)
|| m_snippetOverlay->hasFirstSelectionBeginMoved()) {
m_snippetOverlay->setVisible(false);
m_snippetOverlay->clear();
return false;