Skip to content

Commit d41ccfd

Browse files
authored
Merge pull request #12818 from microsoft/main
2 parents c8b7f13 + 292d84f commit d41ccfd

9 files changed

+81
-60
lines changed

Extension/CHANGELOG.md

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

3+
## Version 1.22.8: October 8, 2024
4+
### Bug Fixes
5+
* Fix an issue with the 'Add #include' code action incorrectly using a relative path for a system include. [#12010](https://github.com/microsoft/vscode-cpptools/issues/12010)
6+
* Fix an issue with lingering incorrect squiggles after an edit. [#12175](https://github.com/microsoft/vscode-cpptools/issues/12175)
7+
* Fix an issue with clang-format/tidy version checks for some builds. [#12806](https://github.com/microsoft/vscode-cpptools/issues/12806)
8+
* Revert/postpone changes related to recursive includes handling due to issues with some projects.
9+
* Fix a memory leak.
10+
311
## Version 1.22.7: September 30, 2024
412
### Enhancement
513
* The .vsix and .js files are now signed. [#12725](https://github.com/microsoft/vscode-cpptools/issues/12725), [#12744](https://github.com/microsoft/vscode-cpptools/issues/12744)
@@ -1377,7 +1385,7 @@
13771385
## Version 0.29.0: July 15, 2020
13781386
### New Features
13791387
* Add Doxygen comment support (to tooltip display of hover, completion, and signature help). [#658](https://github.com/microsoft/vscode-cpptools/issues/658)
1380-
* The way comments are formatted is controlled by the `C_Cpp.simplifyStructuredComments` setting.
1388+
* The way comments are formatted is controlled by the `C_Cpp.simplifyStructuredComments` setting.
13811389
* Auto-convert `.` to `->` when the type is a pointer. [#862](https://github.com/microsoft/vscode-cpptools/issues/862)
13821390
* Switch to using the VS Code Semantic Tokens API for semantic colorization (works with remoting). [PR #5401](https://github.com/microsoft/vscode-cpptools/pull/5401), [#3932](https://github.com/microsoft/vscode-cpptools/issues/3932), [#3933](https://github.com/microsoft/vscode-cpptools/issues/3933), [#3942](https://github.com/microsoft/vscode-cpptools/issues/3942)
13831391
* Add support for LogMessage Breakpoints for debug type `cppdbg`. [PR MIEngine#1013](https://github.com/microsoft/MIEngine/pull/1013)
@@ -2082,7 +2090,7 @@
20822090
## Version 0.16.1: March 30, 2018
20832091
* Fix random deadlock caused by logging code on Linux/Mac. [#1759](https://github.com/Microsoft/vscode-cpptools/issues/1759)
20842092
* Fix compiler from `compileCommands` not being queried for includes/defines if `compilerPath` isn't set on Windows. [#1754](https://github.com/Microsoft/vscode-cpptools/issues/1754)
2085-
* Fix OSX `UseShellExecute` I/O bug. [#1756](https://github.com/Microsoft/vscode-cpptools/issues/1756)
2093+
* Fix OSX `UseShellExecute` I/O bug. [#1756](https://github.com/Microsoft/vscode-cpptools/issues/1756)
20862094
* Invalidate partially unzipped files from package manager. [#1757](https://github.com/Microsoft/vscode-cpptools/issues/1757)
20872095

20882096
## Version 0.16.0: March 28, 2018
@@ -2426,4 +2434,4 @@
24262434

24272435
## Version 0.5.0: April 14, 2016
24282436
* Usability and correctness bug fixes.
2429-
* Simplify installation experience.
2437+
* Simplify installation experience.

Extension/package.json

+1-1
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.7-main",
5+
"version": "1.22.8-main",
66
"publisher": "ms-vscode",
77
"icon": "LanguageCCPP_color_128x.png",
88
"readme": "README.md",

Extension/src/LanguageServer/Providers/callHierarchyProvider.ts

+10-19
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ export interface CallHierarchyParams {
5151

5252
interface CallHierarchyItemResult {
5353
item?: CallHierarchyItem;
54-
55-
/**
56-
* If a request is cancelled, `succeeded` will be undefined to indicate no result was returned.
57-
* Therefore, object is not defined as optional on the language server.
58-
*/
59-
succeeded: boolean;
6054
}
6155

6256
interface CallHierarchyCallsItem {
@@ -137,25 +131,23 @@ export class CallHierarchyProvider implements vscode.CallHierarchyProvider {
137131
}
138132
throw e;
139133
}
140-
cancellationTokenListener.dispose();
141-
requestCanceledListener.dispose();
134+
finally {
135+
cancellationTokenListener.dispose();
136+
requestCanceledListener.dispose();
137+
}
142138

143-
if (cancelSource.token.isCancellationRequested || response.succeeded === undefined) {
144-
// Return undefined instead of vscode.CancellationError to avoid the following error message from VS Code:
145-
// "MISSING provider."
146-
// TODO: per issue https://github.com/microsoft/vscode/issues/169698 vscode.CancellationError is expected,
147-
// so when VS Code fixes the error use vscode.CancellationError again.
148-
return undefined;
149-
} else if (response.item === undefined) {
139+
if (cancelSource.token.isCancellationRequested) {
140+
throw new vscode.CancellationError();
141+
}
142+
if (response.item === undefined) {
150143
return undefined;
151144
}
152145

153146
this.isEntryRootNodeTelemetry = true;
154147
return this.makeVscodeCallHierarchyItem(response.item);
155148
}
156149

157-
public async provideCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken):
158-
Promise<vscode.CallHierarchyIncomingCall[] | undefined> {
150+
public async provideCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[] | undefined> {
159151
await this.client.ready;
160152
workspaceReferences.cancelCurrentReferenceRequest(CancellationSender.NewRequest);
161153

@@ -215,8 +207,7 @@ export class CallHierarchyProvider implements vscode.CallHierarchyProvider {
215207
return result;
216208
}
217209

218-
public async provideCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken):
219-
Promise<vscode.CallHierarchyOutgoingCall[] | undefined> {
210+
public async provideCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[] | undefined> {
220211
const CallHierarchyCallsFromEvent: string = "CallHierarchyCallsFrom";
221212
if (item === undefined) {
222213
this.logTelemetry(CallHierarchyCallsFromEvent, CallHierarchyRequestStatus.Failed);

Extension/src/LanguageServer/Providers/findAllReferencesProvider.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ export class FindAllReferencesProvider implements vscode.ReferenceProvider {
4545
throw e;
4646
}
4747
}
48-
49-
// Reset anything that can be cleared before processing the result.
50-
workspaceReferences.resetProgressBar();
51-
cancellationTokenListener.dispose();
52-
requestCanceledListener.dispose();
48+
finally {
49+
// Reset anything that can be cleared before processing the result.
50+
workspaceReferences.resetProgressBar();
51+
cancellationTokenListener.dispose();
52+
requestCanceledListener.dispose();
53+
}
5354

5455
// Process the result.
5556
if (cancelSource.token.isCancellationRequested || cancelled || (response && response.isCanceled)) {

Extension/src/LanguageServer/Providers/renameProvider.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ export class RenameProvider implements vscode.RenameProvider {
5757
}
5858
throw e;
5959
}
60-
61-
// Reset anything that can be cleared before processing the result.
62-
workspaceReferences.resetProgressBar();
63-
workspaceReferences.resetReferences();
64-
requestCanceledListener.dispose();
60+
finally {
61+
// Reset anything that can be cleared before processing the result.
62+
workspaceReferences.resetProgressBar();
63+
workspaceReferences.resetReferences();
64+
requestCanceledListener.dispose();
65+
}
6566

6667
// Process the result.
6768
if (cancelSource.token.isCancellationRequested || response.isCanceled) {

Extension/src/LanguageServer/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ interface GetIncludesParams {
529529
maxDepth: number;
530530
}
531531

532-
interface GetIncludesResult {
532+
export interface GetIncludesResult {
533533
includedFiles: string[];
534534
}
535535

Extension/src/LanguageServer/extension.ts

+35-9
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as util from '../common';
2020
import { getCrashCallStacksChannel } from '../logger';
2121
import { PlatformInformation } from '../platform';
2222
import * as telemetry from '../telemetry';
23-
import { Client, DefaultClient, DoxygenCodeActionCommandArguments, openFileVersions } from './client';
23+
import { Client, DefaultClient, DoxygenCodeActionCommandArguments, GetIncludesResult, openFileVersions } from './client';
2424
import { ClientCollection } from './clientCollection';
2525
import { CodeActionDiagnosticInfo, CodeAnalysisDiagnosticIdentifiersAndUri, codeAnalysisAllFixes, codeAnalysisCodeToFixes, codeAnalysisFileToCodeActions } from './codeAnalysis';
2626
import { CppBuildTaskProvider } from './cppBuildTaskProvider';
@@ -33,11 +33,22 @@ import { CppSettings } from './settings';
3333
import { LanguageStatusUI, getUI } from './ui';
3434
import { makeLspRange, rangeEquals, showInstallCompilerWalkthrough } from './utils';
3535

36+
interface CopilotTrait {
37+
name: string;
38+
value: string;
39+
includeInPrompt?: boolean;
40+
promptTextOverride?: string;
41+
}
42+
3643
interface CopilotApi {
3744
registerRelatedFilesProvider(
3845
providerId: { extensionId: string; languageId: string },
39-
callback: (uri: vscode.Uri, token: vscode.CancellationToken) => Promise<{ entries: vscode.Uri[]; traits?: { name: string; value: string }[] }>
40-
): vscode.Disposable;
46+
callback: (
47+
uri: vscode.Uri,
48+
context: { flags: Record<string, unknown> },
49+
cancellationToken: vscode.CancellationToken
50+
) => Promise<{ entries: vscode.Uri[]; traits?: CopilotTrait[] }>
51+
): Disposable;
4152
}
4253

4354
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
@@ -270,8 +281,8 @@ export async function activate(): Promise<void> {
270281
for (const languageId of ['c', 'cpp', 'cuda-cpp']) {
271282
api.registerRelatedFilesProvider(
272283
{ extensionId: util.extensionContext.extension.id, languageId },
273-
async (_uri: vscode.Uri, token: vscode.CancellationToken) =>
274-
({ entries: (await clients.ActiveClient.getIncludes(1, token))?.includedFiles.map(file => vscode.Uri.file(file)) ?? [] })
284+
async (_uri: vscode.Uri, _context: { flags: Record<string, unknown> }, token: vscode.CancellationToken) =>
285+
({ entries: (await getIncludesWithCancellation(1, token))?.includedFiles.map(file => vscode.Uri.file(file)) ?? [] })
275286
);
276287
}
277288
} catch {
@@ -1402,13 +1413,28 @@ export async function preReleaseCheck(): Promise<void> {
14021413
}
14031414
}
14041415

1405-
export async function getIncludes(maxDepth: number): Promise<any> {
1406-
const tokenSource = new vscode.CancellationTokenSource();
1407-
const includes = await clients.ActiveClient.getIncludes(maxDepth, tokenSource.token);
1408-
tokenSource.dispose();
1416+
export async function getIncludesWithCancellation(maxDepth: number, token: vscode.CancellationToken): Promise<GetIncludesResult> {
1417+
const includes = await clients.ActiveClient.getIncludes(maxDepth, token);
1418+
const wksFolder = clients.ActiveClient.RootUri?.toString();
1419+
1420+
if (!wksFolder) {
1421+
return includes;
1422+
}
1423+
1424+
includes.includedFiles = includes.includedFiles.filter(header => vscode.Uri.file(header).toString().startsWith(wksFolder));
14091425
return includes;
14101426
}
14111427

1428+
async function getIncludes(maxDepth: number): Promise<GetIncludesResult> {
1429+
const tokenSource = new vscode.CancellationTokenSource();
1430+
try {
1431+
const includes = await getIncludesWithCancellation(maxDepth, tokenSource.token);
1432+
return includes;
1433+
} finally {
1434+
tokenSource.dispose();
1435+
}
1436+
}
1437+
14121438
async function getCopilotApi(): Promise<CopilotApi | undefined> {
14131439
const copilotExtension = vscode.extensions.getExtension<CopilotApi>('github.copilot');
14141440
if (!copilotExtension) {

Extension/src/LanguageServer/lmTool.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ const knownValues: { [Property in keyof ChatContextResult]?: { [id: string]: str
4646

4747
const plainTextContentType = 'text/plain';
4848

49-
export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTool {
50-
public async invoke(options: vscode.LanguageModelToolInvocationOptions, token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult> {
49+
export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTool<void> {
50+
public async invoke(options: vscode.LanguageModelToolInvocationOptions<void>, token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult> {
5151
const result: vscode.LanguageModelToolResult = {};
5252
if (options.requestedContentTypes.includes(plainTextContentType)) {
5353
result[plainTextContentType] = await this.getContext(token);

Extension/src/LanguageServer/settings.ts

+9-15
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ export class CppSettings extends Settings {
277277
if (cachedClangPath !== undefined) {
278278
return cachedClangPath;
279279
}
280-
const clangStr: string = isFormat ? this.clangFormatStr : this.clangTidyStr;
281280
const clangName: string = isFormat ? this.clangFormatName : this.clangTidyName;
282281
const setCachedClangPath: (path: string) => void = isFormat ? setCachedClangFormatPath : setCachedClangTidyPath;
283282
const whichPath: string | null = which.sync(clangName, { nothrow: true });
@@ -290,29 +289,24 @@ export class CppSettings extends Settings {
290289
return undefined;
291290
} else {
292291
// Attempt to invoke both our own version of clang-* to see if we can successfully execute it, and to get its version.
293-
let clangVersion: string;
292+
let bundledVersion: string;
294293
try {
295-
const exePath: string = getExtensionFilePath(`./LLVM/bin/${clangName}`);
296-
const output: string[] = execSync(quote([exePath, '--version'])).toString().split(" ");
297-
if (output.length < 3 || output[0] !== clangStr || output[1] !== "version" || !semver.valid(output[2])) {
298-
if (output.length === 3) {
299-
return path;
300-
}
301-
const versionIndex: number = output.findIndex((value: string) => value === "version");
302-
if (versionIndex < 0 || versionIndex + 1 >= output.length || !semver.valid(output[versionIndex + 1].trim())) {
303-
return path;
304-
}
294+
const bundledPath: string = getExtensionFilePath(`./LLVM/bin/${clangName}`);
295+
const output: string = execSync(quote([bundledPath, '--version'])).toString();
296+
bundledVersion = output.match(/(\d+\.\d+\.\d+)/)?.[1] ?? "";
297+
if (!semver.valid(bundledVersion)) {
298+
return path;
305299
}
306-
clangVersion = output[2];
307300
} catch (e) {
308301
// Unable to invoke our own clang-*. Use the system installed clang-*.
309302
return path;
310303
}
311304

312305
// Invoke the version on the system to compare versions. Use ours if it's more recent.
313306
try {
314-
const output: string[] = execSync(`"${path}" --version`).toString().split(" ");
315-
if (output.length < 3 || output[0] !== clangStr || output[1] !== "version" || semver.ltr(output[2], clangVersion)) {
307+
const output: string = execSync(`"${path}" --version`).toString();
308+
const userVersion = output.match(/(\d+\.\d+\.\d+)/)?.[1] ?? "";
309+
if (semver.ltr(userVersion, bundledVersion)) {
316310
path = "";
317311
setCachedClangPath(path);
318312
}

0 commit comments

Comments
 (0)