Skip to content

Commit 7d26dd1

Browse files
authored
Merge pull request #12932 from microsoft/main
Merge for 1.23.1
2 parents 381d696 + 1b21b69 commit 7d26dd1

File tree

6 files changed

+80
-65
lines changed

6 files changed

+80
-65
lines changed

Extension/CHANGELOG.md

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

3+
### Version 1.23.1: November 6, 2024
4+
### Bug Fixes
5+
* A potential fix for a crash during process shutdown (in `uv_run`). [#12668](https://github.com/microsoft/vscode-cpptools/issues/12668)
6+
* Fix a performance issue where some LSP requests would delay other LSP requests. [#12905](https://github.com/microsoft/vscode-cpptools/issues/12905)
7+
* A potential fix for a crash in cpptools (in `report_intellisense_results`).
8+
* Fix a random deadlock in `handle_edits`.
9+
* Other internal fixes.
10+
11+
## Version 1.22.11: November 5, 2024
12+
### Bug Fixes
13+
* Fix system includes incorrectly being treated as non-system includes when specified with `-I`. [#12842](https://github.com/microsoft/vscode-cpptools/issues/12842)
14+
* Fix inactive region ranges when multi-byte UTF-8 characters are used. [#12879](https://github.com/microsoft/vscode-cpptools/issues/12879)
15+
* Fix formatting with `.editorconfig` files. [#12921](https://github.com/microsoft/vscode-cpptools/issues/12921)
16+
317
## Version 1.23.0: October 29, 2024
418
### Enhancements
519
* Update to clang-format and clang-tidy 19.1.2. [#12824](https://github.com/microsoft/vscode-cpptools/issues/12824)

Extension/package.json

+2-2
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.23.0-main",
5+
"version": "1.23.1-main",
66
"publisher": "ms-vscode",
77
"icon": "LanguageCCPP_color_128x.png",
88
"readme": "README.md",
@@ -6511,7 +6511,7 @@
65116511
"translations-generate": "set NODE_OPTIONS=--no-experimental-fetch && gulp translations-generate",
65126512
"translations-import": "gulp translations-import",
65136513
"import-edge-strings": "ts-node -T ./.scripts/import_edge_strings.ts",
6514-
"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)",
65156515
"build": "yarn prep:dts && echo [Building TypeScript code] && tsc --build tsconfig.json"
65166516
},
65176517
"devDependencies": {

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),

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
}

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

Extension/src/LanguageServer/protocolFilter.ts

+18-44
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as path from 'path';
88
import * as vscode from 'vscode';
99
import { Middleware } from 'vscode-languageclient';
1010
import * as util from '../common';
11+
import { logAndReturn } from '../Utility/Async/returns';
1112
import { Client } from './client';
1213
import { clients } from './extension';
1314
import { shouldChangeFromCToCpp } from './utils';
@@ -18,14 +19,8 @@ export const ServerCancelled: number = -32802;
1819
let anyFileOpened: boolean = false;
1920

2021
export function createProtocolFilter(): Middleware {
21-
// Disabling lint for invoke handlers
22-
const invoke1 = (a: any, next: (a: any) => any): any => clients.ActiveClient.enqueue(() => next(a));
23-
const invoke2 = (a: any, b: any, next: (a: any, b: any) => any): any => clients.ActiveClient.enqueue(() => next(a, b));
24-
const invoke3 = (a: any, b: any, c: any, next: (a: any, b: any, c: any) => any): any => clients.ActiveClient.enqueue(() => next(a, b, c));
25-
const invoke4 = (a: any, b: any, c: any, d: any, next: (a: any, b: any, c: any, d: any) => any): any => clients.ActiveClient.enqueue(() => next(a, b, c, d));
26-
2722
return {
28-
didOpen: async (document, sendMessage) => clients.ActiveClient.enqueue(async () => {
23+
didOpen: async (document, sendMessage) => {
2924
if (!util.isCpp(document)) {
3025
return;
3126
}
@@ -41,62 +36,41 @@ export function createProtocolFilter(): Middleware {
4136
const mappingString: string = baseFileName + "@" + document.fileName;
4237
client.addFileAssociations(mappingString, "cpp");
4338
client.sendDidChangeSettings();
44-
document = await vscode.languages.setTextDocumentLanguage(document, "cpp");
39+
// This will cause the file to be closed and reopened.
40+
void vscode.languages.setTextDocumentLanguage(document, "cpp");
41+
return;
4542
}
4643
// client.takeOwnership() will call client.TrackedDocuments.add() again, but that's ok. It's a Set.
4744
client.onDidOpenTextDocument(document);
4845
client.takeOwnership(document);
49-
await sendMessage(document);
50-
51-
// For a file already open when we activate, sometimes we don't get any notifications about visible
52-
// or active text editors, visible ranges, or text selection. As a workaround, we trigger
53-
// onDidChangeVisibleTextEditors here, only for the first file opened.
54-
if (!anyFileOpened) {
55-
anyFileOpened = true;
56-
const cppEditors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => util.isCpp(e.document));
57-
await client.onDidChangeVisibleTextEditors(cppEditors);
58-
}
46+
void sendMessage(document).then(() => {
47+
// For a file already open when we activate, sometimes we don't get any notifications about visible
48+
// or active text editors, visible ranges, or text selection. As a workaround, we trigger
49+
// onDidChangeVisibleTextEditors here, only for the first file opened.
50+
if (!anyFileOpened) {
51+
anyFileOpened = true;
52+
const cppEditors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => util.isCpp(e.document));
53+
client.onDidChangeVisibleTextEditors(cppEditors).catch(logAndReturn.undefined);
54+
}
55+
});
5956
}
6057
}
61-
}),
62-
didChange: invoke1,
63-
willSave: invoke1,
58+
},
6459
willSaveWaitUntil: async (event, sendMessage) => {
65-
// await clients.ActiveClient.ready;
66-
// Don't use awaitUntilLanguageClientReady.
67-
// Otherwise, the message can be delayed too long.
6860
const me: Client = clients.getClientFor(event.document.uri);
6961
if (me.TrackedDocuments.has(event.document.uri.toString())) {
7062
return sendMessage(event);
7163
}
7264
return [];
7365
},
74-
didSave: invoke1,
75-
didClose: async (document, sendMessage) => clients.ActiveClient.enqueue(async () => {
66+
didClose: async (document, sendMessage) => {
7667
const me: Client = clients.getClientFor(document.uri);
7768
const uriString: string = document.uri.toString();
7869
if (me.TrackedDocuments.has(uriString)) {
7970
me.onDidCloseTextDocument(document);
8071
me.TrackedDocuments.delete(uriString);
81-
await sendMessage(document);
82-
}
83-
}),
84-
provideCompletionItem: invoke4,
85-
resolveCompletionItem: invoke2,
86-
provideHover: async (document, position, token, next: (document: any, position: any, token: any) => any) => clients.ActiveClient.enqueue(async () => {
87-
const me: Client = clients.getClientFor(document.uri);
88-
if (me.TrackedDocuments.has(document.uri.toString())) {
89-
return next(document, position, token);
72+
void sendMessage(document);
9073
}
91-
return null;
92-
}),
93-
provideSignatureHelp: invoke4,
94-
provideDefinition: invoke3,
95-
provideReferences: invoke4,
96-
provideDocumentHighlights: invoke3,
97-
provideDeclaration: invoke3,
98-
workspace: {
99-
didChangeConfiguration: invoke1
10074
}
10175
};
10276
}

0 commit comments

Comments
 (0)