From f56fd04c8dbbfead7800a1612fb0d1fd05ceeca6 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 1 Mar 2024 13:43:27 +0100 Subject: [PATCH] Revert "Clangd: Avoid client restart after modifying open documents" The whole point of tracking external changes to files is to use the open files as a sentinel to indicate that non-open files (on which we don't have a watch) have likely also been changed. This reverts commit cff26d813a8805c34588536ca19453852b946643. Change-Id: I5a8b3e6709eda881b912916cf0838b45d1ff4fa4 Reviewed-by: David Schulz Reviewed-by: Reviewed-by: Qt CI Bot --- .../clangcodemodel/clangmodelmanagersupport.cpp | 5 ----- src/plugins/clangcodemodel/test/clangdtests.cpp | 10 ++++++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp index 477ab9104b9..3cf94e19c7c 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp @@ -796,11 +796,6 @@ void ClangModelManagerSupport::watchForExternalChanges() if (!LanguageClientManager::hasClients()) 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 1edec4c2905..bfe7ea95368 100644 --- a/src/plugins/clangcodemodel/test/clangdtests.cpp +++ b/src/plugins/clangcodemodel/test/clangdtests.cpp @@ -2207,15 +2207,21 @@ 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 diagnostics in the current editor. + // verify that we get a new client and 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(client(), &ClangdClient::textMarkCreated, timeOutInMs())); + QVERIFY(waitForSignalOrTimeout(newClient, &ClangdClient::textMarkCreated, timeOutInMs())); }