Priority: P1: Critical
Affects Version/s: Qt Creator 6.0.0-beta1
Fix Version/s: Qt Creator 5.0.3
Component/s: Language Server Protocol (LSP) Support
Commits:dc40af5fa57f6ed5cfd9cfecb3d8f09e8de726f8 (qt-creator/tqtc-qt-creator/5.0) 07cfae77ba (qt-creator/qt-creator/qmlprojectstorage)
1. Enable clangd in the C++ settings.
2. Create a project with a simple source file that triggers a diagnostic, e.g.:
3. Open the file (not the project!). A diagnostic will appear (though somewhat subdued, because the file has no project).
4. Now open the project; don't close the file.
5. Observe that no diagnostics are shown anymore. It will stay that way until you close and re-open the file (editing does not help).
At step 4, our clangd support closes the document in the fallback client and opens it in the project-specific client. The LSP inspector shows that this does indeed result in didClose and didOpen messages in the expected order. (Possibly relevant, or not: The server sends a diagnostics message with an empty list of diagnostics to the fallback client right after receiving the didClose message.) The inspector also shows that the project-specific server sends correct diagnostics messages. Debugging shows that for these, Client::handleDiagnostics() does not call m_diagnosticManager.showDiagnostics(), because LanguageClientManager::clientForUri() does not return the right client. Apparently, the document -> client map is not properly updated.
The issue appears to be 100% reproducible.
Note that the problem is relevant in practice because of sessions.