forked from qt-creator/qt-creator
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 <david.schulz@qt.io>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user