From 1ebc364349bbae3f22ea7e3d96adaa81fb5411eb Mon Sep 17 00:00:00 2001
From: David Schulz <david.schulz@qt.io>
Date: Mon, 17 Jul 2017 14:32:59 +0200
Subject: [PATCH] TextEditor: Jump over braces inserted by the
 TextDocumentManipulator
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Task-number: QTCREATORBUG-16946
Change-Id: I445c5698da59230f1d6ae859e6bbf20d26fc5bb9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
---
 src/plugins/texteditor/texteditor.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index 7e8c1c2345d..ba1dd248bdb 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -7431,7 +7431,10 @@ void TextEditorWidget::keepAutoCompletionHighlight(bool keepHighlight)
 void TextEditorWidget::setAutoCompleteSkipPosition(const QTextCursor &cursor)
 {
     QTextCursor tc = cursor;
-    tc.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+    // Create a selection of the next character but keep the current position, otherwise
+    // the cursor would be removed from the list of automatically inserted text positions
+    tc.movePosition(QTextCursor::NextCharacter);
+    tc.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
     d->autocompleterHighlight(tc);
 }
 
-- 
GitLab