From 416cd69a5e7ab9e900320181a637ce30a40b9c4d Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 1 Nov 2021 11:02:58 +0100 Subject: [PATCH] Editor: unselect text on mouse release event Update the main cursor after calling QPlainTextEdit::mouseReleaseEvent. Calling that function might change the selection without changing the position, so it wont emit cursor position changed, and the multi cursor does not get updated properly. Task-number: QTCREATORBUG-26493 Change-Id: Ie310ee9a4c66897766af87065ee42fcd01302854 Reviewed-by: Christian Stenger --- src/plugins/texteditor/texteditor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index a54732ec39f..59ac0bba32c 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -5245,6 +5245,14 @@ void TextEditorWidget::mouseReleaseEvent(QMouseEvent *e) return; QPlainTextEdit::mouseReleaseEvent(e); + + d->setClipboardSelection(); + const QTextCursor plainTextEditCursor = textCursor(); + const QTextCursor multiMainCursor = multiTextCursor().mainCursor(); + if (multiMainCursor.position() != plainTextEditCursor.position() + || multiMainCursor.anchor() != plainTextEditCursor.anchor()) { + doSetTextCursor(plainTextEditCursor, true); + } } void TextEditorWidget::mouseDoubleClickEvent(QMouseEvent *e)