Skip to content

Commit

Permalink
Fix document corruption due to delayed evaluation in protocolFilter (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Colengms authored and sean-mcmanus committed Dec 6, 2022
1 parent c22c28d commit ac74b5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions Extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
* Fix clang-tidy and clang-format not working on CentOS7 and other Linux OS's without glibc 2.27 or greater. [#10019](https://github.com/microsoft/vscode-cpptools/issues/10019)
* Fix various bugs with the `C_Cpp.codeAnalysis.clangTidy.headerFilter` setting. [#10023](https://github.com/microsoft/vscode-cpptools/issues/10023)
* Fix Doxygen comment generation when there's a selection. [#10028](https://github.com/microsoft/vscode-cpptools/issues/10028)
* Fix issue that could cause document corruption. [#10035](https://github.com/microsoft/vscode-cpptools/issues/10035)
* Fixed crash on Linux/Mac when a full command line is specified in `compilerPath` containing invalid arguments. [PR #10070](https://github.com/microsoft/vscode-cpptools/pull/10070)
* Fix random "Failed to spawn IntelliSense process: 65520" on Mac. [#10091](https://github.com/microsoft/vscode-cpptools/issues/10091)
* Fix "Don't hardcode path to kill in UnixUtilities". [#10124](https://github.com/microsoft/vscode-cpptools/issues/10124)
Expand Down
21 changes: 8 additions & 13 deletions Extension/src/LanguageServer/protocolFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Middleware } from 'vscode-languageclient';
import { Client } from './client';
import * as vscode from 'vscode';
import { CppSettings } from './settings';
import { clients, onDidChangeActiveTextEditor, processDelayedDidOpen } from './extension';
import { clients, onDidChangeActiveTextEditor } from './extension';

export function createProtocolFilter(): Middleware {
// Disabling lint for invoke handlers
Expand All @@ -36,13 +36,11 @@ export function createProtocolFilter(): Middleware {
me.TrackedDocuments.add(document);
const finishDidOpen = (doc: vscode.TextDocument) => {
me.provideCustomConfiguration(doc.uri, undefined);
me.notifyWhenLanguageClientReady(() => {
sendMessage(doc);
me.onDidOpenTextDocument(doc);
if (editor && editor === vscode.window.activeTextEditor) {
onDidChangeActiveTextEditor(editor);
}
});
sendMessage(doc);
me.onDidOpenTextDocument(doc);
if (editor && editor === vscode.window.activeTextEditor) {
onDidChangeActiveTextEditor(editor);
}
};
let languageChanged: boolean = false;
if ((document.uri.path.endsWith(".C") || document.uri.path.endsWith(".H")) && document.languageId === "c") {
Expand Down Expand Up @@ -75,11 +73,8 @@ export function createProtocolFilter(): Middleware {
},
didChange: async (textDocumentChangeEvent, sendMessage) => {
const me: Client = clients.getClientFor(textDocumentChangeEvent.document.uri);
if (!me.TrackedDocuments.has(textDocumentChangeEvent.document)) {
processDelayedDidOpen(textDocumentChangeEvent.document);
}
me.onDidChangeTextDocument(textDocumentChangeEvent);
me.notifyWhenLanguageClientReady(() => sendMessage(textDocumentChangeEvent));
sendMessage(textDocumentChangeEvent);
},
willSave: defaultHandler,
willSaveWaitUntil: async (event, sendMessage) => {
Expand All @@ -97,7 +92,7 @@ export function createProtocolFilter(): Middleware {
if (me.TrackedDocuments.has(document)) {
me.onDidCloseTextDocument(document);
me.TrackedDocuments.delete(document);
me.notifyWhenLanguageClientReady(() => sendMessage(document));
sendMessage(document);
}
},

Expand Down

0 comments on commit ac74b5b

Please sign in to comment.