Skip to content

Commit 8b06e7d

Browse files
authored
Merge pull request #6607 from microsoft/seanmcm/1_1_3
Merge for 1.1.3 release
2 parents 16f3521 + b102143 commit 8b06e7d

9 files changed

Lines changed: 73 additions & 49 deletions

File tree

Extension/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# C/C++ for Visual Studio Code Change Log
22

3+
## Version 1.1.3: December 3, 2020
4+
### Bug Fixes
5+
* Disable the "join Insiders" prompt for Linux CodeSpaces. [#6491](https://github.com/microsoft/vscode-cpptools/issues/6491)
6+
* Fix "shell" tasks giving error "Cannot read property `includes` of undefined". [#6538](https://github.com/microsoft/vscode-cpptools/issues/6538)
7+
* Fix various task variables not getting resolved with `cppbuild` tasks. [#6538](https://github.com/microsoft/vscode-cpptools/issues/6538)
8+
* Fix warnings not appearing with `cppbuild` tasks. [#6556](https://github.com/microsoft/vscode-cpptools/issues/6556)
9+
* Fix endless CPU/memory usage if the cpptools process crashes. [#6603](https://github.com/microsoft/vscode-cpptools/issues/6603)
10+
311
## Version 1.1.2: November 17, 2020
412
### Bug Fix
513
* Fix resolution of `${fileDirname}` with `cppbuild` tasks. [#6386](https://github.com/microsoft/vscode-cpptools/issues/6386)

Extension/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cpptools",
33
"displayName": "C/C++",
44
"description": "C/C++ IntelliSense, debugging, and code browsing.",
5-
"version": "1.1.2",
5+
"version": "1.1.3",
66
"publisher": "ms-vscode",
77
"icon": "LanguageCCPP_color_128x.png",
88
"readme": "README.md",
@@ -2347,7 +2347,7 @@
23472347
"@types/plist": "^3.0.2",
23482348
"@types/semver": "^7.1.0",
23492349
"@types/tmp": "^0.1.0",
2350-
"@types/vscode": "1.44.0",
2350+
"@types/vscode": "1.49.0",
23512351
"@types/webpack": "^4.39.0",
23522352
"@types/which": "^1.3.2",
23532353
"@types/yauzl": "^2.9.1",

Extension/src/Debugger/configurationProvider.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,16 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
150150
}
151151
// Filter out build tasks that don't match the currently selected debug configuration type.
152152
buildTasks = buildTasks.filter((task: CppBuildTask) => {
153+
const command: string = task.definition.command as string;
154+
if (!command) {
155+
return false;
156+
}
153157
if (defaultConfig.name.startsWith("(Windows) ")) {
154-
if ((task.definition.command as string).includes("cl.exe")) {
158+
if (command.includes("cl.exe")) {
155159
return true;
156160
}
157161
} else {
158-
if (!(task.definition.command as string).includes("cl.exe")) {
162+
if (!command.includes("cl.exe")) {
159163
return true;
160164
}
161165
}

Extension/src/Debugger/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function initialize(context: vscode.ExtensionContext): void {
5050
// Not enabled because we do not react to single-file mode correctly yet.
5151
// We get an ENOENT when the user's c_cpp_properties.json is attempted to be parsed.
5252
// The DefaultClient will also have its configuration accessed, but since it doesn't exist it errors out.
53-
vscode.window.showErrorMessage('This command is not yet available for single-file mode.');
53+
vscode.window.showErrorMessage(localize("single_file_mode_not_available", "This command is not available for single-file mode."));
5454
return Promise.resolve();
5555
}
5656

Extension/src/LanguageServer/clientCollection.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ export class ClientCollection {
9191
}
9292

9393
public forEach(callback: (client: cpptools.Client) => void): void {
94-
this.languageClients.forEach(callback);
94+
// Copy this.languageClients to languageClients to avoid an infinite foreach loop
95+
// when callback modifies this.languageClients (e.g. when cpptools crashes).
96+
const languageClients: cpptools.Client[] = [];
97+
this.languageClients.forEach(client => languageClients.push(client));
98+
languageClients.forEach(callback);
9599
}
96100

97101
public checkOwnership(client: cpptools.Client, document: vscode.TextDocument): boolean {

Extension/src/LanguageServer/configurations.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ export class CppProperties {
246246
}
247247

248248
private onConfigurationsChanged(): void {
249-
this.configurationsChanged.fire(this.Configurations);
249+
if (this.Configurations) {
250+
this.configurationsChanged.fire(this.Configurations);
251+
}
250252
}
251253

252254
private onSelectionChanged(): void {

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* ------------------------------------------------------------------------------------------ */
55
import * as path from 'path';
66
import {
7-
TaskDefinition, Task, TaskGroup, WorkspaceFolder, ShellExecution, Uri, workspace,
7+
TaskDefinition, Task, TaskGroup, ShellExecution, Uri, workspace,
88
TaskProvider, TaskScope, CustomExecution, ProcessExecution, TextEditor, Pseudoterminal, EventEmitter, Event, TerminalDimensions, window
99
} from 'vscode';
1010
import * as os from 'os';
@@ -15,6 +15,10 @@ import * as configs from './configurations';
1515
import * as ext from './extension';
1616
import * as cp from "child_process";
1717
import { OtherSettings } from './settings';
18+
import * as nls from 'vscode-nls';
19+
20+
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
21+
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
1822

1923
export interface CppBuildTaskDefinition extends TaskDefinition {
2024
type: string;
@@ -156,7 +160,7 @@ export class CppBuildTaskProvider implements TaskProvider {
156160

157161
if (!definition) {
158162
const taskLabel: string = ((appendSourceToName && !compilerPathBase.startsWith(CppBuildTaskProvider.CppBuildSourceStr)) ?
159-
CppBuildTaskProvider.CppBuildSourceStr + ": " : "") + compilerPathBase + " build active file";
163+
CppBuildTaskProvider.CppBuildSourceStr + ": " : "") + compilerPathBase + " " + localize("build_active_file", "build active file");
160164
const filePath: string = path.join('${fileDirname}', '${fileBasenameNoExtension}');
161165
const isWindows: boolean = os.platform() === 'win32';
162166
let args: string[] = isCl ? ['/Zi', '/EHsc', '/Fe:', filePath + '.exe', '${file}'] : ['-g', '${file}', '-o', filePath + (isWindows ? '.exe' : '')];
@@ -185,13 +189,13 @@ export class CppBuildTaskProvider implements TaskProvider {
185189

186190
const scope: TaskScope = TaskScope.Workspace;
187191
const task: CppBuildTask = new Task(definition, scope, definition.label, CppBuildTaskProvider.CppBuildSourceStr,
188-
new CustomExecution(async (): Promise<Pseudoterminal> =>
192+
new CustomExecution(async (resolvedDefinition: TaskDefinition): Promise<Pseudoterminal> =>
189193
// When the task is executed, this callback will run. Here, we setup for running the task.
190-
new CustomBuildTaskTerminal(resolvedcompilerPath, definition ? definition.args : [], definition ? definition.options : undefined)
194+
new CustomBuildTaskTerminal(resolvedcompilerPath, resolvedDefinition.args, resolvedDefinition.options)
191195
), isCl ? '$msCompile' : '$gcc');
192196

193197
task.group = TaskGroup.Build;
194-
task.detail = detail ? detail : "compiler: " + resolvedcompilerPath;
198+
task.detail = detail ? detail : localize("compiler_details", "compiler:") + " " + resolvedcompilerPath;
195199

196200
return task;
197201
};
@@ -200,6 +204,9 @@ export class CppBuildTaskProvider implements TaskProvider {
200204
const rawJson: any = await this.getRawTasksJson();
201205
const rawTasksJson: any = (!rawJson.tasks) ? new Array() : rawJson.tasks;
202206
const buildTasksJson: CppBuildTask[] = rawTasksJson.map((task: any) => {
207+
if (!task.label) {
208+
return null;
209+
}
203210
const definition: CppBuildTaskDefinition = {
204211
type: task.type,
205212
label: task.label,
@@ -211,7 +218,7 @@ export class CppBuildTaskProvider implements TaskProvider {
211218
cppBuildTask.detail = task.detail;
212219
return cppBuildTask;
213220
});
214-
return buildTasksJson;
221+
return buildTasksJson.filter((task: CppBuildTask) => task !== null);
215222
}
216223

217224
public async ensureBuildTaskExists(taskLabel: string): Promise<void> {
@@ -252,7 +259,7 @@ export class CppBuildTaskProvider implements TaskProvider {
252259
...selectedTask.definition,
253260
problemMatcher: selectedTask.problemMatchers,
254261
group: { kind: "build", "isDefault": true },
255-
detail: "Generated task by Debugger"
262+
detail: localize("task_generated_by_debugger", "Task generated by Debugger.")
256263
};
257264
rawTasksJson.tasks.push(newTask);
258265
}
@@ -333,7 +340,7 @@ class CustomBuildTaskTerminal implements Pseudoterminal {
333340
async open(_initialDimensions: TerminalDimensions | undefined): Promise<void> {
334341
telemetry.logLanguageServerEvent("cppBuildTaskStarted");
335342
// At this point we can start using the terminal.
336-
this.writeEmitter.fire(`Starting build...${this.endOfLine}`);
343+
this.writeEmitter.fire(localize("starting_build", "Starting build...") + this.endOfLine);
337344
await this.doBuild();
338345
}
339346

@@ -343,16 +350,16 @@ class CustomBuildTaskTerminal implements Pseudoterminal {
343350

344351
private async doBuild(): Promise<any> {
345352
// Do build.
346-
let activeCommand: string = util.resolveVariables(this.command, this.AdditionalEnvironment);
353+
let activeCommand: string = util.resolveVariables(this.command);
347354
this.args.forEach(value => {
348-
let temp: string = util.resolveVariables(value, this.AdditionalEnvironment);
355+
let temp: string = util.resolveVariables(value);
349356
if (temp && temp.includes(" ")) {
350357
temp = "\"" + temp + "\"";
351358
}
352359
activeCommand = activeCommand + " " + temp;
353360
});
354361
if (this.options?.cwd) {
355-
this.options.cwd = util.resolveVariables(this.options.cwd, this.AdditionalEnvironment);
362+
this.options.cwd = util.resolveVariables(this.options.cwd);
356363
}
357364

358365
const splitWriteEmitter = (lines: string | Buffer) => {
@@ -363,16 +370,34 @@ class CustomBuildTaskTerminal implements Pseudoterminal {
363370
try {
364371
const result: number = await new Promise<number>((resolve, reject) => {
365372
cp.exec(activeCommand, this.options, (_error, stdout, _stderr) => {
373+
const dot: string = (stdout || _stderr) ? ":" : ".";
366374
if (_error) {
367375
telemetry.logLanguageServerEvent("cppBuildTaskError");
368-
const dot: string = (stdout || _stderr) ? ":" : ".";
369-
this.writeEmitter.fire(`Build finished with error${dot}${this.endOfLine}`);
370-
splitWriteEmitter(stdout);
371-
splitWriteEmitter(_stderr);
376+
this.writeEmitter.fire(localize("build_finished_with_error", "Build finished with errors(s)") + dot + this.endOfLine);
377+
if (stdout) {
378+
splitWriteEmitter(stdout); // cl.exe
379+
} else if (_stderr) {
380+
splitWriteEmitter(_stderr); // gcc/clang
381+
} else {
382+
splitWriteEmitter(_error.message); // e.g. command executable not found
383+
}
372384
resolve(-1);
373-
} else {
385+
return;
386+
} else if (_stderr && !stdout) { // gcc/clang
387+
telemetry.logLanguageServerEvent("cppBuildTaskWarnings");
388+
this.writeEmitter.fire(localize("build_finished_with_warnings", "Build finished with warning(s)") + dot + this.endOfLine);
389+
splitWriteEmitter(_stderr);
390+
resolve(0);
391+
} else if (stdout && stdout.includes("warning C")) { // cl.exe
392+
telemetry.logLanguageServerEvent("cppBuildTaskWarnings");
393+
this.writeEmitter.fire(localize("build_finished_with_warnings", "Build finished with warning(s)") + dot + this.endOfLine);
374394
splitWriteEmitter(stdout);
375-
this.writeEmitter.fire(`Build finished successfully.${this.endOfLine}`);
395+
resolve(0);
396+
} else {
397+
if (stdout) {
398+
splitWriteEmitter(stdout); // cl.exe
399+
}
400+
this.writeEmitter.fire(localize("build finished successfully", "Build finished successfully.") + this.endOfLine);
376401
resolve(0);
377402
}
378403
});
@@ -382,23 +407,4 @@ class CustomBuildTaskTerminal implements Pseudoterminal {
382407
this.closeEmitter.fire(-1);
383408
}
384409
}
385-
386-
private get AdditionalEnvironment(): { [key: string]: string | string[] } | undefined {
387-
const editor: TextEditor | undefined = window.activeTextEditor;
388-
if (!editor) {
389-
return undefined;
390-
}
391-
const fileDir: WorkspaceFolder | undefined = workspace.getWorkspaceFolder(editor.document.uri);
392-
if (!fileDir) {
393-
window.showErrorMessage('This command is not yet available for single-file mode.');
394-
return undefined;
395-
}
396-
const file: string = editor.document.fileName;
397-
return {
398-
"file": file,
399-
"fileDirname": path.parse(file).dir,
400-
"fileBasenameNoExtension": path.parse(file).name,
401-
"workspaceFolder": fileDir.uri.fsPath
402-
};
403-
}
404410
}

Extension/src/LanguageServer/referencesTreeDataProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const localize: nls.LocalizeFunc = nls.loadMessageBundle();
1313

1414
export class ReferencesTreeDataProvider implements vscode.TreeDataProvider<TreeNode> {
1515
private referencesModel: ReferencesModel | undefined;
16-
private readonly _onDidChangeTreeData = new vscode.EventEmitter<TreeNode>();
17-
readonly onDidChangeTreeData: vscode.Event<TreeNode>;
16+
private readonly _onDidChangeTreeData = new vscode.EventEmitter<void>();
17+
readonly onDidChangeTreeData: vscode.Event<void>;
1818

1919
constructor() {
2020
this.onDidChangeTreeData = this._onDidChangeTreeData.event;

Extension/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@
204204
dependencies:
205205
source-map "^0.6.1"
206206

207-
"@types/vscode@1.44.0":
208-
version "1.44.0"
209-
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.44.0.tgz#62ecfe3d0e38942fce556574da54ee1013c775b7"
210-
integrity sha512-WJZtZlinE3meRdH+I7wTsIhpz/GLhqEQwmPGeh4s1irWLwMzCeTV8WZ+pgPTwrDXoafVUWwo1LiZ9HJVHFlJSQ==
207+
"@types/vscode@1.49.0":
208+
version "1.49.0"
209+
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.49.0.tgz#f3731d97d7e8b2697510eb26f6e6d04ee8c17352"
210+
integrity sha512-wfNQmLmm1VdMBr6iuNdprWmC1YdrgZ9dQzadv+l2eSjJlElOdJw8OTm4RU4oGTBcfvG6RZI2jOcppkdSS18mZw==
211211

212212
"@types/webpack-sources@*":
213213
version "0.1.6"

0 commit comments

Comments
 (0)