forked from qt-creator/qt-creator
Clangd: Avoid client restart after modifying open documents
Change-Id: I116eed1b047159e3d1ce64f18f44da6a0ad7b231 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -683,6 +683,11 @@ 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;
|
||||||
|
@@ -2052,21 +2052,15 @@ 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 a new client and diagnostics in the current editor.
|
// verify that we get 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(newClient, &ClangdClient::textMarkCreated, timeOutInMs()));
|
QVERIFY(waitForSignalOrTimeout(client(), &ClangdClient::textMarkCreated, timeOutInMs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangdTestIndirectChanges::ClangdTestIndirectChanges()
|
ClangdTestIndirectChanges::ClangdTestIndirectChanges()
|
||||||
|
Reference in New Issue
Block a user