forked from qt-creator/qt-creator
Clang: Fix processing documents if multiple are opened at once
Reproducable with 1. $ ./qtcreator a.cpp b.cpp 2. Switch to a.cpp => no highlighting Because ClangEditorDocumentProcessor does asynchronous processing, the backend might receive a DocumentsOpenedMessage where the document is not the current editor (happens for a.cpp in the example). When switching to that document, the initial jobs were not processed as the document was not dirty. Address this case by also checking for documents that have a revision of 1 and are not dirty. Unify adding the annotations jobs to ensure that not more than needed are run. Change-Id: I14030260842f97d58280235e763c8d7490705f8d Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -258,6 +258,21 @@ TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForClosedDocument)
|
||||
closeDocument(filePathA);
|
||||
}
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, AnnotationsForInitiallyNotVisibleDocument)
|
||||
{
|
||||
const int expectedAnnotationsCount = 2;
|
||||
updateProjectPart();
|
||||
updateVisibilty(filePathA, filePathA);
|
||||
expectAnnotations(expectedAnnotationsCount);
|
||||
clangServer.documentsOpened( // Open document while another is still visible
|
||||
DocumentsOpenedMessage({FileContainer(filePathB, projectPartId, Utf8String(), false, 1)},
|
||||
filePathA, {filePathA}));
|
||||
clangServer.unsavedFilesUpdated( // Invalidate added jobs
|
||||
UnsavedFilesUpdatedMessage({FileContainer(Utf8StringLiteral("aFile"), Utf8String())}));
|
||||
|
||||
updateVisibilty(filePathB, filePathB);
|
||||
}
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, NoAnnotationsForClosedDocument)
|
||||
{
|
||||
const int expectedAnnotationsCount = AnnotationJobsMultiplier; // Only for registration.
|
||||
|
||||
Reference in New Issue
Block a user