Skip to content

Commit

Permalink
Merge branch 'main' into seanmcm/1_2_0_insiders_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-mcmanus committed Jan 15, 2021
2 parents f7cab67 + 8e8482b commit ed584b2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@ export function processDelayedDidOpen(document: vscode.TextDocument): void {
const client: Client = clients.getClientFor(document.uri);
if (client) {
// Log warm start.
clients.timeTelemetryCollector.setDidOpenTime(document.uri);
if (clients.checkOwnership(client, document)) {
if (!client.TrackedDocuments.has(document)) {
// If not yet tracked, process as a newly opened file. (didOpen is sent to server in client.takeOwnership()).
clients.timeTelemetryCollector.setDidOpenTime(document.uri);
client.TrackedDocuments.add(document);
const finishDidOpen = (doc: vscode.TextDocument) => {
client.provideCustomConfiguration(doc.uri, undefined);
Expand Down
58 changes: 30 additions & 28 deletions Extension/src/LanguageServer/protocolFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,42 @@ export function createProtocolFilter(clients: ClientCollection): Middleware {
didOpen: (document, sendMessage) => {
const editor: vscode.TextEditor | undefined = vscode.window.visibleTextEditors.find(e => e.document === document);
if (editor) {
// Log warm start.
clients.timeTelemetryCollector.setDidOpenTime(document.uri);
// If the file was visible editor when we were activated, we will not get a call to
// onDidChangeVisibleTextEditors, so immediately open any file that is visible when we receive didOpen.
// Otherwise, we defer opening the file until it's actually visible.
const me: Client = clients.getClientFor(document.uri);
if (clients.checkOwnership(me, document)) {
me.TrackedDocuments.add(document);
const finishDidOpen = (doc: vscode.TextDocument) => {
me.provideCustomConfiguration(doc.uri, undefined);
me.notifyWhenReady(() => {
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") {
const cppSettings: CppSettings = new CppSettings();
if (cppSettings.autoAddFileAssociations) {
const fileName: string = path.basename(document.uri.fsPath);
const mappingString: string = fileName + "@" + document.uri.fsPath;
me.addFileAssociations(mappingString, false);
me.sendDidChangeSettings({ files: { associations: new OtherSettings().filesAssociations }});
vscode.languages.setTextDocumentLanguage(document, "cpp").then((newDoc: vscode.TextDocument) => {
finishDidOpen(newDoc);
if (!me.TrackedDocuments.has(document)) {
// Log warm start.
clients.timeTelemetryCollector.setDidOpenTime(document.uri);
if (clients.checkOwnership(me, document)) {
me.TrackedDocuments.add(document);
const finishDidOpen = (doc: vscode.TextDocument) => {
me.provideCustomConfiguration(doc.uri, undefined);
me.notifyWhenReady(() => {
sendMessage(doc);
me.onDidOpenTextDocument(doc);
if (editor && editor === vscode.window.activeTextEditor) {
onDidChangeActiveTextEditor(editor);
}
});
languageChanged = true;
};
let languageChanged: boolean = false;
if ((document.uri.path.endsWith(".C") || document.uri.path.endsWith(".H")) && document.languageId === "c") {
const cppSettings: CppSettings = new CppSettings();
if (cppSettings.autoAddFileAssociations) {
const fileName: string = path.basename(document.uri.fsPath);
const mappingString: string = fileName + "@" + document.uri.fsPath;
me.addFileAssociations(mappingString, false);
me.sendDidChangeSettings({ files: { associations: new OtherSettings().filesAssociations }});
vscode.languages.setTextDocumentLanguage(document, "cpp").then((newDoc: vscode.TextDocument) => {
finishDidOpen(newDoc);
});
languageChanged = true;
}
}
if (!languageChanged) {
finishDidOpen(document);
}
}
if (!languageChanged) {
finishDidOpen(document);
}
}
} else {
Expand Down

0 comments on commit ed584b2

Please sign in to comment.