Skip to content

Commit 7ff83d5

Browse files
authored
Remove shallow document copy and prevent extension activation on Untitled (#4144)
* Remove shallow document copy and prevent extension activation on Untitled.
1 parent d51ae12 commit 7ff83d5

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

Extension/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# C/C++ for Visual Studio Code Change Log
22

3-
## Version 0.25.1: August 26, 2019
3+
## Version 0.25.1: August 27, 2019
44
### Bug Fixes
55
* Fix `Switch Header/Source` for `.H` and `.C` targets. [#3048](https://github.com/microsoft/vscode-cpptools/issues/3048)
6+
* Fix duplicate content appearing after formatting of a new file (2nd fix). [#4091](https://github.com/microsoft/vscode-cpptools/issues/4091)
67
* Fix links in `Log Diagnostics` output. [#4122](https://github.com/microsoft/vscode-cpptools/issues/4122)
78
* Fix `NullReferenceException` when debugging if `"description"` is missing. [#4125}(https://github.com/microsoft/vscode-cpptools/issues/4125)
89
* Fix `files.exclude` processing when using `\\`. [#4127](https://github.com/microsoft/vscode-cpptools/issues/4127)
10+
* Fix bug when attaching to an elevated process using GDB. [#4133](https://github.com/microsoft/vscode-cpptools/issues/4133)
11+
* Fix IntelliSense-based `Go to Definition` failing for a nested class in a template class. [#4135](https://github.com/microsoft/vscode-cpptools/issues/4135)
12+
* Fix incorrect configuration squiggles with `compilerPath` when variables are used. [#4141](https://github.com/microsoft/vscode-cpptools/issues/4141)
13+
* @mistersandman [PR #4142](https://github.com/microsoft/vscode-cpptools/pull/4142)
914

1015
## Version 0.25.0: August 21, 2019
1116
### New Features

Extension/src/LanguageServer/extension.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,11 @@ export function activate(activationEventOccurred: boolean): void {
220220
if (vscode.workspace.textDocuments !== undefined && vscode.workspace.textDocuments.length > 0) {
221221
for (let i: number = 0; i < vscode.workspace.textDocuments.length; ++i) {
222222
let document: vscode.TextDocument = vscode.workspace.textDocuments[i];
223-
if (document.languageId === "cpp" || document.languageId === "c") {
224-
onActivationEvent();
225-
return;
223+
if (document.uri.scheme === "file") {
224+
if (document.languageId === "cpp" || document.languageId === "c") {
225+
onActivationEvent();
226+
return;
227+
}
226228
}
227229
}
228230
}
@@ -517,7 +519,7 @@ function onDidChangeActiveTextEditor(editor: vscode.TextEditor): void {
517519
}
518520

519521
let activeEditor: vscode.TextEditor = vscode.window.activeTextEditor;
520-
if (!activeEditor || (activeEditor.document.languageId !== "cpp" && activeEditor.document.languageId !== "c")) {
522+
if (!activeEditor || activeEditor.document.uri.scheme !== "file" || (activeEditor.document.languageId !== "cpp" && activeEditor.document.languageId !== "c")) {
521523
activeDocument = "";
522524
} else {
523525
activeDocument = editor.document.uri.toString();
@@ -530,6 +532,7 @@ function onDidChangeActiveTextEditor(editor: vscode.TextEditor): void {
530532
function onDidChangeTextEditorSelection(event: vscode.TextEditorSelectionChangeEvent): void {
531533
/* need to notify the affected client(s) */
532534
if (!event.textEditor || !vscode.window.activeTextEditor || event.textEditor.document.uri !== vscode.window.activeTextEditor.document.uri ||
535+
event.textEditor.document.uri.scheme !== "file" ||
533536
(event.textEditor.document.languageId !== "cpp" && event.textEditor.document.languageId !== "c")) {
534537
return;
535538
}

Extension/src/LanguageServer/protocolFilter.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
'use strict';
66

77
import * as path from 'path';
8-
import { TextDocument } from 'vscode';
98
import { Middleware } from 'vscode-languageclient';
109
import { ClientCollection } from './clientCollection';
1110
import { Client } from './client';
@@ -35,13 +34,8 @@ export function createProtocolFilter(me: Client, clients: ClientCollection): Mid
3534

3635
me.onDidOpenTextDocument(document);
3736

38-
// 'document' is a reference to the live TextDocument. Because the document can change while we wait for
39-
// custom configurations, we must clone the current state of the object before yielding the thread.
40-
// Theoretically, we should do this everywhere, but there are no other callbacks that read the document
41-
// state directly (just the Uri) so there doesn't appear to be a need to do it.
42-
const documentCopy: TextDocument = {...document};
4337
me.provideCustomConfiguration(document.uri, null);
44-
me.notifyWhenReady(() => sendMessage(documentCopy));
38+
me.notifyWhenReady(() => sendMessage(document));
4539
}
4640
},
4741
didChange: (textDocumentChangeEvent, sendMessage) => {

Extension/src/LanguageServer/ui.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class UI {
158158

159159
public activeDocumentChanged(): void {
160160
let activeEditor: vscode.TextEditor = vscode.window.activeTextEditor;
161-
let isCpp: boolean = (activeEditor && (activeEditor.document.languageId === "cpp" || activeEditor.document.languageId === "c"));
161+
let isCpp: boolean = (activeEditor && activeEditor.document.uri.scheme === "file" && (activeEditor.document.languageId === "cpp" || activeEditor.document.languageId === "c"));
162162

163163
// It's sometimes desirable to see the config and icons when making settings changes.
164164
let isSettingsJson: boolean = (activeEditor && (activeEditor.document.fileName.endsWith("c_cpp_properties.json") || activeEditor.document.fileName.endsWith("settings.json")));

0 commit comments

Comments
 (0)