forked from qt-creator/qt-creator
LanguageClient: Increment document version on every content change
Prevents applying results from outdated documents. Specifically notifications and codeactions for documents that have been cleared on the contents change handler but get a result before sending the actual did change notification. Change-Id: I640088d7cb2464dd4edd832319314bb04eab1df3 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -721,6 +721,7 @@ void Client::documentContentsChanged(TextEditor::TextDocument *document,
|
|||||||
m_openedDocument[document] = document->plainText();
|
m_openedDocument[document] = document->plainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++m_documentVersions[document->filePath()];
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
for (BaseTextEditor *editor : BaseTextEditor::textEditorsForDocument(document)) {
|
for (BaseTextEditor *editor : BaseTextEditor::textEditorsForDocument(document)) {
|
||||||
if (TextEditorWidget *widget = editor->editorWidget()) {
|
if (TextEditorWidget *widget = editor->editorWidget()) {
|
||||||
@@ -1187,7 +1188,7 @@ void Client::sendPostponedDocumentUpdates()
|
|||||||
const auto uri = DocumentUri::fromFilePath(filePath);
|
const auto uri = DocumentUri::fromFilePath(filePath);
|
||||||
m_highlights[uri].clear();
|
m_highlights[uri].clear();
|
||||||
VersionedTextDocumentIdentifier docId(uri);
|
VersionedTextDocumentIdentifier docId(uri);
|
||||||
docId.setVersion(++m_documentVersions[filePath]);
|
docId.setVersion(m_documentVersions[filePath]);
|
||||||
DidChangeTextDocumentParams params;
|
DidChangeTextDocumentParams params;
|
||||||
params.setTextDocument(docId);
|
params.setTextDocument(docId);
|
||||||
params.setContentChanges(m_documentsToUpdate.take(document));
|
params.setContentChanges(m_documentsToUpdate.take(document));
|
||||||
|
|||||||
Reference in New Issue
Block a user