Skip to content

Commit 203624e

Browse files
authored
Merge pull request #12927 from microsoft/main
Merge to vs
2 parents 8bae3c4 + 390046c commit 203624e

File tree

10 files changed

+108
-77
lines changed

10 files changed

+108
-77
lines changed

Diff for: Extension/CHANGELOG.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
# C/C++ for Visual Studio Code Changelog
22

3+
## Version 1.23.0: October 29, 2024
4+
### Enhancements
5+
* Update to clang-format and clang-tidy 19.1.2. [#12824](https://github.com/microsoft/vscode-cpptools/issues/12824)
6+
* Enable `#cpp` with GitHub Copilot chat without `C_Cpp.experimentalFeatures` enabled. [PR #12898](https://github.com/microsoft/vscode-cpptools/pull/12898)
7+
8+
### Bug Fixes
9+
* Fix some translation issues. [#7824](https://github.com/microsoft/vscode-cpptools/issues/7824), [#12439](https://github.com/microsoft/vscode-cpptools/issues/12439), [#12440](https://github.com/microsoft/vscode-cpptools/issues/12440), [#12441](https://github.com/microsoft/vscode-cpptools/issues/12441)
10+
* Fix a bug with 'Select IntelliSense Configuration'. [#12705](https://github.com/microsoft/vscode-cpptools/issues/12705)
11+
* Fix newlines being removed from hover markdown code blocks. [#12794](https://github.com/microsoft/vscode-cpptools/issues/12794)
12+
* Fix clang-format using `-` instead of `--` args. [#12819](https://github.com/microsoft/vscode-cpptools/issues/12819)
13+
* Fix processing of `compile_commands.json` generated by the clang `-MJ` option. [#12837](https://github.com/microsoft/vscode-cpptools/issues/12837)
14+
* Fix handling of `-I` and `-isystem` with the same path. [#12842](https://github.com/microsoft/vscode-cpptools/issues/12842)
15+
* Fix stale colorization due to delays in updating the open file version. [PR #12851](https://github.com/microsoft/vscode-cpptools/pull/12851)
16+
* Fix redundant progressive squiggle updates. [PR #12876](https://github.com/microsoft/vscode-cpptools/pull/12876)
17+
* Fix inactive regions with multi-byte UTF-8 characters. [#12879](https://github.com/microsoft/vscode-cpptools/issues/12879)
18+
* Fix some duplicate requests potentially not getting discarded.
19+
* Fix a random crash in `start_process_and_wait_for_exit`.
20+
321
## Version 1.22.10: October 21, 2024
422
### Bug Fixes
523
* Fix the 'Extract to Function' feature not working.
624
* Fix the 'Go to Next/Prev Preprocessor Conditional' feature not working.
725

8-
## Version 1.22.9: October 10, 2024
26+
## Version 1.22.9: October 14, 2024
927
### Performance Improvements
1028
* Initialization performance improvements. [#12030](https://github.com/microsoft/vscode-cpptools/issues/12030)
1129
- Some processing is parallelized and started earlier (populating the filename cache, discovering files). [#11954](https://github.com/microsoft/vscode-cpptools/issues/11954), [#12169](https://github.com/microsoft/vscode-cpptools/issues/12169)

Diff for: Extension/package.json

+3-4
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.22.9-main",
5+
"version": "1.23.0-main",
66
"publisher": "ms-vscode",
77
"icon": "LanguageCCPP_color_128x.png",
88
"readme": "README.md",
@@ -38,8 +38,7 @@
3838
"Snippets"
3939
],
4040
"enabledApiProposals": [
41-
"terminalDataWriteEvent",
42-
"lmTools"
41+
"terminalDataWriteEvent"
4342
],
4443
"capabilities": {
4544
"untrustedWorkspaces": {
@@ -6512,7 +6511,7 @@
65126511
"translations-generate": "set NODE_OPTIONS=--no-experimental-fetch && gulp translations-generate",
65136512
"translations-import": "gulp translations-import",
65146513
"import-edge-strings": "ts-node -T ./.scripts/import_edge_strings.ts",
6515-
"prep:dts": "yarn verify dts --quiet || (npx vscode-dts dev && npx vscode-dts main)",
6514+
"prep:dts": "yarn verify dts --quiet || (npx @vscode/dts dev && npx @vscode/dts main)",
65166515
"build": "yarn prep:dts && echo [Building TypeScript code] && tsc --build tsconfig.json"
65176516
},
65186517
"devDependencies": {

Diff for: Extension/src/Debugger/configurationProvider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
331331

332332
// Run deploy steps
333333
if (config.deploySteps && config.deploySteps.length !== 0) {
334-
const codeVersion: number[] = vscode.version.split('.').map(num => parseInt(num, undefined));
334+
const codeVersion: number[] = util.getVsCodeVersion();
335335
if ((util.isNumber(codeVersion[0]) && codeVersion[0] < 1) || (util.isNumber(codeVersion[0]) && codeVersion[0] === 1 && util.isNumber(codeVersion[1]) && codeVersion[1] < 69)) {
336336
void logger.getOutputChannelLogger().showErrorMessage(localize("vs.code.1.69+.required", "'deploySteps' require VS Code 1.69+."));
337337
return undefined;

Diff for: Extension/src/LanguageServer/client.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ export class DefaultClient implements Client {
10461046
if (index === paths.length - 1) {
10471047
action = "disable";
10481048
settings.defaultCompilerPath = "";
1049-
await this.configuration.updateCompilerPathIfSet(settings.defaultCompilerPath);
1049+
await this.configuration.updateCompilerPathIfSet("");
10501050
configurationSelected = true;
10511051
await this.showPrompt(sender);
10521052
return ui.ShowConfigureIntelliSenseButton(false, this, ConfigurationType.CompilerPath, "disablePrompt");
@@ -1066,7 +1066,7 @@ export class DefaultClient implements Client {
10661066
configurationSelected = true;
10671067
action = "compiler browsed";
10681068
settings.defaultCompilerPath = result[0].fsPath;
1069-
await this.configuration.updateCompilerPathIfSet(settings.defaultCompilerPath);
1069+
await this.configuration.updateCompilerPathIfSet(result[0].fsPath);
10701070
void SessionState.trustedCompilerFound.set(true);
10711071
} else {
10721072
configurationSelected = true;
@@ -1084,8 +1084,9 @@ export class DefaultClient implements Client {
10841084
return ui.ShowConfigureIntelliSenseButton(false, this, ConfigurationType.CompileCommands, showButtonSender);
10851085
} else {
10861086
action = "select compiler";
1087-
settings.defaultCompilerPath = util.isCl(paths[index]) ? "cl.exe" : paths[index];
1088-
await this.configuration.updateCompilerPathIfSet(settings.defaultCompilerPath);
1087+
const newCompiler: string = util.isCl(paths[index]) ? "cl.exe" : paths[index];
1088+
settings.defaultCompilerPath = newCompiler;
1089+
await this.configuration.updateCompilerPathIfSet(newCompiler);
10891090
void SessionState.trustedCompilerFound.set(true);
10901091
}
10911092
}
@@ -2387,7 +2388,9 @@ export class DefaultClient implements Client {
23872388
}
23882389

23892390
this.updateInactiveRegions(intelliSenseResult.uri, intelliSenseResult.inactiveRegions, intelliSenseResult.clearExistingInactiveRegions, intelliSenseResult.isCompletePass);
2390-
this.updateSquiggles(intelliSenseResult.uri, intelliSenseResult.diagnostics, intelliSenseResult.clearExistingDiagnostics);
2391+
if (intelliSenseResult.clearExistingDiagnostics || intelliSenseResult.diagnostics.length > 0) {
2392+
this.updateSquiggles(intelliSenseResult.uri, intelliSenseResult.diagnostics, intelliSenseResult.clearExistingDiagnostics);
2393+
}
23912394
}
23922395

23932396
private updateSquiggles(uriString: string, diagnostics: IntelliSenseDiagnostic[], startNewSet: boolean): void {

Diff for: Extension/src/LanguageServer/configurations.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ export class CppProperties {
19481948
compilerPath = checkPathExists.path;
19491949
}
19501950
if (!compilerPathExists) {
1951-
compilerMessage = localize('cannot.find2', "Cannot find \"{0}\".", compilerPath);
1951+
compilerMessage = localize('cannot.find', "Cannot find: {0}", compilerPath);
19521952
newSquiggleMetrics.PathNonExistent++;
19531953
}
19541954
if (compilerMessage) {
@@ -1975,7 +1975,7 @@ export class CppProperties {
19751975
dotConfigPath = checkPathExists.path;
19761976
}
19771977
if (!dotConfigPathExists) {
1978-
dotConfigMessage = localize('cannot.find2', "Cannot find \"{0}\".", dotConfigPath);
1978+
dotConfigMessage = localize('cannot.find', "Cannot find: {0}", dotConfigPath);
19791979
newSquiggleMetrics.PathNonExistent++;
19801980
} else if (dotConfigPath && !util.checkFileExistsSync(dotConfigPath)) {
19811981
dotConfigMessage = localize("path.is.not.a.file", "Path is not a file: {0}", dotConfigPath);
@@ -2083,7 +2083,7 @@ export class CppProperties {
20832083
} else {
20842084
badPath = `"${expandedPaths[0]}"`;
20852085
}
2086-
message = localize('cannot.find2', "Cannot find {0}", badPath);
2086+
message = localize('cannot.find', "Cannot find: {0}", badPath);
20872087
newSquiggleMetrics.PathNonExistent++;
20882088
} else {
20892089
// Check for file versus path mismatches.
@@ -2141,7 +2141,7 @@ export class CppProperties {
21412141
endOffset = curOffset + curMatch.length;
21422142
let message: string;
21432143
if (!pathExists) {
2144-
message = localize('cannot.find2', "Cannot find \"{0}\".", expandedPaths[0]);
2144+
message = localize('cannot.find', "Cannot find: {0}", expandedPaths[0]);
21452145
newSquiggleMetrics.PathNonExistent++;
21462146
const diagnostic: vscode.Diagnostic = new vscode.Diagnostic(
21472147
new vscode.Range(document.positionAt(envTextStartOffSet + curOffset),

Diff for: Extension/src/LanguageServer/editorConfig.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,17 @@ function parseEditorConfigContent(content: string): Record<string, any> {
9292
const [key, ...values] = line.split('=');
9393
if (key && values.length > 0) {
9494
const trimmedKey = key.trim();
95-
const value = values.join('=').trim();
95+
let value: any = values.join('=').trim();
96+
97+
// Convert boolean-like and numeric values.
98+
if (value.toLowerCase() === 'true') {
99+
value = true;
100+
} else if (value.toLowerCase() === 'false') {
101+
value = false;
102+
} else if (!isNaN(Number(value))) {
103+
value = Number(value);
104+
}
105+
96106
if (currentSection) {
97107
// Ensure the current section is initialized.
98108
if (!config[currentSection]) {
@@ -114,7 +124,7 @@ function getEditorConfig(filePath: string): any {
114124
const rootDir: string = path.parse(currentDir).root;
115125

116126
// Traverse from the file's directory to the root directory.
117-
for (;;) {
127+
for (; ;) {
118128
const editorConfigPath: string = path.join(currentDir, '.editorconfig');
119129
if (fs.existsSync(editorConfigPath)) {
120130
const configFileContent: string = fs.readFileSync(editorConfigPath, 'utf-8');
@@ -139,7 +149,7 @@ function getEditorConfig(filePath: string): any {
139149
});
140150

141151
// Check if the current .editorconfig is the root.
142-
if (configData['*']?.root?.toLowerCase() === 'true') {
152+
if (configData['*']?.root) {
143153
break; // Stop searching after processing the root = true file.
144154
}
145155
}

Diff for: Extension/src/LanguageServer/extension.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,15 @@ export async function activate(): Promise<void> {
252252
activeDocument = activeEditor.document;
253253
}
254254

255-
if (util.extensionContext && new CppSettings().experimentalFeatures) {
256-
const tool = vscode.lm.registerTool('cpptools-lmtool-configuration', new CppConfigurationLanguageModelTool());
257-
disposables.push(tool);
255+
if (util.extensionContext) {
256+
// lmTools wasn't stabilized until 1.95, but (as of October 2024)
257+
// cpptools can be installed on older versions of VS Code. See
258+
// https://github.com/microsoft/vscode-cpptools/blob/main/Extension/package.json#L14
259+
const version = util.getVsCodeVersion();
260+
if (version[0] > 1 || (version[0] === 1 && version[1] >= 95)) {
261+
const tool = vscode.lm.registerTool('cpptools-lmtool-configuration', new CppConfigurationLanguageModelTool());
262+
disposables.push(tool);
263+
}
258264
}
259265

260266
await registerRelatedFilesProvider();

Diff for: Extension/src/LanguageServer/lmTool.ts

+29-12
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
5151
}
5252

5353
private async getContext(token: vscode.CancellationToken): Promise<string> {
54+
const telemetryProperties: Record<string, string> = {};
5455
try {
5556
const currentDoc = vscode.window.activeTextEditor?.document;
5657
if (!currentDoc || (!util.isCpp(currentDoc) && !util.isHeaderFile(currentDoc.uri))) {
@@ -62,28 +63,44 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
6263
return 'No configuration information is available for the active document.';
6364
}
6465

65-
telemetry.logLanguageModelToolEvent(
66-
'cpp',
67-
{
68-
"language": chatContext.language,
69-
"compiler": chatContext.compiler,
70-
"standardVersion": chatContext.standardVersion,
71-
"targetPlatform": chatContext.targetPlatform,
72-
"targetArchitecture": chatContext.targetArchitecture
73-
});
74-
7566
for (const key in knownValues) {
7667
const knownKey = key as keyof ChatContextResult;
7768
if (knownValues[knownKey] && chatContext[knownKey]) {
78-
chatContext[knownKey] = knownValues[knownKey][chatContext[knownKey]] || chatContext[knownKey];
69+
// Clear the value if it's not in the known values.
70+
chatContext[knownKey] = knownValues[knownKey][chatContext[knownKey]] || "";
7971
}
8072
}
8173

82-
return `The user is working on a ${chatContext.language} project. The project uses language version ${chatContext.standardVersion}, compiles using the ${chatContext.compiler} compiler, targets the ${chatContext.targetPlatform} platform, and targets the ${chatContext.targetArchitecture} architecture.`;
74+
let contextString = "";
75+
if (chatContext.language) {
76+
contextString += `The user is working on a ${chatContext.language} project. `;
77+
telemetryProperties["language"] = chatContext.language;
78+
}
79+
if (chatContext.standardVersion) {
80+
contextString += `The project uses language version ${chatContext.standardVersion}. `;
81+
telemetryProperties["standardVersion"] = chatContext.standardVersion;
82+
}
83+
if (chatContext.compiler) {
84+
contextString += `The project compiles using the ${chatContext.compiler} compiler. `;
85+
telemetryProperties["compiler"] = chatContext.compiler;
86+
}
87+
if (chatContext.targetPlatform) {
88+
contextString += `The project targets the ${chatContext.targetPlatform} platform. `;
89+
telemetryProperties["targetPlatform"] = chatContext.targetPlatform;
90+
}
91+
if (chatContext.targetArchitecture) {
92+
contextString += `The project targets the ${chatContext.targetArchitecture} architecture. `;
93+
telemetryProperties["targetArchitecture"] = chatContext.targetArchitecture;
94+
}
95+
96+
return contextString;
8397
}
8498
catch {
8599
await this.reportError();
100+
telemetryProperties["error"] = "true";
86101
return "";
102+
} finally {
103+
telemetry.logLanguageModelToolEvent('cpp', telemetryProperties);
87104
}
88105
}
89106

0 commit comments

Comments
 (0)