From 15419cb1454d7691c3b093c4ca3692c6dfe1be47 Mon Sep 17 00:00:00 2001 From: Alexis Murzeau Date: Sun, 26 Apr 2020 21:35:49 +0200 Subject: [PATCH] LSP: Fix completion assist that could be the wrong provider When a document is opened that uses a language server, it would not gain the completion assitance from the language server in some cases. Instead, the default completion assist provider is used, which in case of the TextEditor, will only provide basic autocompletion. The reason is that Client::activateDocument is not called if the document is not in LanguageClientManager::m_clientForDocument when Client::openDocument is called. The check is at the end of that function. When the issue happens, openDocument is called indirectly from LanguageClientManager::documentOpened. The fix is to change the order of instructions in LanguageClientManager::documentOpened so m_clientForDocument is updated before calling openDocumentWithClient. This way, the language server's completion assist is really used as it should. Change-Id: I0d2b3b8573e97c0c0c4bd517775668d41a4a797b Reviewed-by: David Schulz --- src/plugins/languageclient/languageclientmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/languageclient/languageclientmanager.cpp b/src/plugins/languageclient/languageclientmanager.cpp index b2c65f511b7..dc686dd9d8a 100644 --- a/src/plugins/languageclient/languageclientmanager.cpp +++ b/src/plugins/languageclient/languageclientmanager.cpp @@ -458,9 +458,9 @@ void LanguageClientManager::documentOpened(Core::IDocument *document) clients << startClient(setting); } for (auto client : clients) { - openDocumentWithClient(textDocument, client); if (!m_clientForDocument.contains(textDocument)) m_clientForDocument[textDocument] = client; + openDocumentWithClient(textDocument, client); } } }