diff options
author | David Schulz <[email protected]> | 2023-11-16 10:13:05 +0100 |
---|---|---|
committer | David Schulz <[email protected]> | 2023-11-17 05:38:13 +0000 |
commit | cff26d813a8805c34588536ca19453852b946643 (patch) | |
tree | 99c59fbfb254f0d21136fd9fcfd8102b16d7d662 /src/plugins | |
parent | 7affb80fc386652ba544bb7812f109caf08d39ab (diff) |
Clangd: Avoid client restart after modifying open documents
Change-Id: I116eed1b047159e3d1ce64f18f44da6a0ad7b231
Reviewed-by: Christian Kandeler <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/clangcodemodel/clangmodelmanagersupport.cpp | 5 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/test/clangdtests.cpp | 10 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp index a25ceef0ff5..9d0cd2c0241 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp @@ -683,6 +683,11 @@ void ClangModelManagerSupport::watchForExternalChanges() if (!LanguageClientManager::hasClients<ClangdClient>()) return; for (const FilePath &file : files) { + if (TextEditor::TextDocument::textDocumentForFilePath(file)) { + // if we have a document for that file we should receive the content + // change via the document signals + continue; + } const ProjectFile::Kind kind = ProjectFile::classify(file.toString()); if (!ProjectFile::isSource(kind) && !ProjectFile::isHeader(kind)) continue; diff --git a/src/plugins/clangcodemodel/test/clangdtests.cpp b/src/plugins/clangcodemodel/test/clangdtests.cpp index bfc6d1d4f8d..984aac6e779 100644 --- a/src/plugins/clangcodemodel/test/clangdtests.cpp +++ b/src/plugins/clangcodemodel/test/clangdtests.cpp @@ -2052,21 +2052,15 @@ void ClangdTestExternalChanges::test() QVERIFY(curDoc->marks().isEmpty()); // Now trigger an external change in an open, but not currently visible file and - // verify that we get a new client and diagnostics in the current editor. + // verify that we get diagnostics in the current editor. TextDocument * const docToChange = document("mainwindow.cpp"); docToChange->setSilentReload(); QFile otherSource(filePath("mainwindow.cpp").toString()); QVERIFY(otherSource.open(QIODevice::WriteOnly)); otherSource.write("blubb"); otherSource.close(); - QVERIFY(waitForSignalOrTimeout(LanguageClientManager::instance(), - &LanguageClientManager::clientAdded, timeOutInMs())); - ClangdClient * const newClient = ClangModelManagerSupport::clientForProject(project()); - QVERIFY(newClient); - QVERIFY(newClient != oldClient); - newClient->enableTesting(); if (curDoc->marks().isEmpty()) - QVERIFY(waitForSignalOrTimeout(newClient, &ClangdClient::textMarkCreated, timeOutInMs())); + QVERIFY(waitForSignalOrTimeout(client(), &ClangdClient::textMarkCreated, timeOutInMs())); } ClangdTestIndirectChanges::ClangdTestIndirectChanges() |