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 cff26d813a.

Change-Id: I5a8b3e6709eda881b912916cf0838b45d1ff4fa4
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Christian Kandeler
2024-03-01 13:43:27 +01:00
parent cf8a8974ed
commit f56fd04c8d
2 changed files with 8 additions and 7 deletions

View File

@@ -796,11 +796,6 @@ void ClangModelManagerSupport::watchForExternalChanges()
if (!LanguageClientManager::hasClients<ClangdClient>()) if (!LanguageClientManager::hasClients<ClangdClient>())
return; return;
for (const FilePath &file : files) { 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()); const ProjectFile::Kind kind = ProjectFile::classify(file.toString());
if (!ProjectFile::isSource(kind) && !ProjectFile::isHeader(kind)) if (!ProjectFile::isSource(kind) && !ProjectFile::isHeader(kind))
continue; continue;

View File

@@ -2207,15 +2207,21 @@ void ClangdTestExternalChanges::test()
QVERIFY(curDoc->marks().isEmpty()); QVERIFY(curDoc->marks().isEmpty());
// Now trigger an external change in an open, but not currently visible file and // 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"); TextDocument * const docToChange = document("mainwindow.cpp");
docToChange->setSilentReload(); docToChange->setSilentReload();
QFile otherSource(filePath("mainwindow.cpp").toString()); QFile otherSource(filePath("mainwindow.cpp").toString());
QVERIFY(otherSource.open(QIODevice::WriteOnly)); QVERIFY(otherSource.open(QIODevice::WriteOnly));
otherSource.write("blubb"); otherSource.write("blubb");
otherSource.close(); 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()) if (curDoc->marks().isEmpty())
QVERIFY(waitForSignalOrTimeout(client(), &ClangdClient::textMarkCreated, timeOutInMs())); QVERIFY(waitForSignalOrTimeout(newClient, &ClangdClient::textMarkCreated, timeOutInMs()));
} }