Skip to content

Commit 99d98af

Browse files
authored
Merge pull request #13021 from microsoft/main
Merge to insiders for 1.23.2
2 parents 784f145 + 44b736e commit 99d98af

18 files changed

+1087
-192
lines changed

.github/workflows/ci_mac.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
job:
1111
uses: ./.github/workflows/job-compile-and-test.yml
1212
with:
13-
runner-env: macos-12
13+
runner-env: macos-14
1414
platform: mac
1515
yarn-args: --network-timeout 100000

CODEOWNERS

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Each line is a file pattern followed by one or more owners.
2+
3+
# These owners will be the default owners for everything in
4+
# the repo. Unless a later match takes precedence,
5+
# @microsoft/cpptools-maintainers will be requested for
6+
# review when someone opens a pull request.
7+
8+
* @microsoft/cpptools-maintainers

Extension/CHANGELOG.md

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

3+
### Version 1.23.2: December 5, 2024
4+
### Enhancements
5+
* Add handling of `-fno-char8_t` and `-fchar8_t` compiler arguments. [#12968](https://github.com/microsoft/vscode-cpptools/issues/12968)
6+
* Add support for providing well-known compiler argument information to Copilot Completions. [PR #12979](https://github.com/microsoft/vscode-cpptools/pull/12979)
7+
* Fixed unnecessary cancellation of Copilot context requests. [PR #12988](https://github.com/microsoft/vscode-cpptools/pull/12988)
8+
* Add support for passing an additional parameter to `C_Cpp.ConfigurationSelect` command. [PR #12993](https://github.com/microsoft/vscode-cpptools/pull/12993)
9+
* Thank you for the contribution. [@adrianstephens](https://github.com/adrianstephens)
10+
* Update clang-format and clang-tidy from 19.1.2 to 19.1.5.
11+
* Changes to how paths are internally canonicalized on Linux and macOS, avoiding file system access to improve performance and delay resolution of symbolic links.
12+
13+
### Bug Fixes
14+
* Increase clang-format timeout from 10 seconds to 30 seconds. [#10213](https://github.com/microsoft/vscode-cpptools/issues/10213)
15+
* Fix casing of path in include completion tooltip on Windows. [#12895](https://github.com/microsoft/vscode-cpptools/issues/12895)
16+
* Fix pattern matching of sections in `.editorConfig` files. [#12933](https://github.com/microsoft/vscode-cpptools/issues/12933)
17+
* Fix handling of relative paths passed to cl.exe `/reference` argument. [#12944](https://github.com/microsoft/vscode-cpptools/issues/12944)
18+
* Fix a leak of compile command file watchers. [#12946](https://github.com/microsoft/vscode-cpptools/issues/12946)
19+
* Thank you for the contribution. [@yiftahw](https://github.com/yiftahw) [PR #12948](https://github.com/microsoft/vscode-cpptools/pull/12948)
20+
* Fix a compile commands fallback logic issue. [#12947](https://github.com/microsoft/vscode-cpptools/issues/12947)
21+
* Thank you for the contribution. [@yiftahw](https://github.com/yiftahw) [PR #12948](https://github.com/microsoft/vscode-cpptools/pull/12948)
22+
* Fix an issue in which a `didOpen` event was processed before the language client was fully started. [#12954](https://github.com/microsoft/vscode-cpptools/issues/12954)
23+
* Fix IntelliSense issues related to large header files (>32K) and encodings other than UTF-8.
24+
325
### Version 1.23.1: November 6, 2024
426
### Bug Fixes
527
* A potential fix for a crash during process shutdown (in `uv_run`). [#12668](https://github.com/microsoft/vscode-cpptools/issues/12668)

Extension/ThirdPartyNotices.txt

+26
Original file line numberDiff line numberDiff line change
@@ -2429,6 +2429,7 @@ The notices below are from non-npm sources.
24292429
- ANTLR (http://www.antlr2.org/)
24302430
- C++11 Sublime Text Snippets (https://github.com/Rapptz/cpp-sublime-snippet)
24312431
- Clang (https://clang.llvm.org/)
2432+
- editorconfig-core-js (https://github.com/editorconfig/editorconfig-core-js)
24322433
- gcc-11/libgcc (https://packages.ubuntu.com/jammy/gcc-11-base)
24332434
- Guidelines Support Library (https://github.com/Microsoft/GSL)
24342435
- libc++ (https://libcxx.llvm.org/index.html)
@@ -2677,6 +2678,31 @@ mechanisms:
26772678
=========================================
26782679
END OF Clang NOTICES AND INFORMATION
26792680

2681+
%% editorconfig-core-js NOTICES AND INFORMATION BEGIN HERE
2682+
=========================================
2683+
Copyright © 2012 EditorConfig Team
2684+
2685+
Permission is hereby granted, free of charge, to any person obtaining a copy
2686+
of this software and associated documentation files (the “Software”), to deal
2687+
in the Software without restriction, including without limitation the rights
2688+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2689+
copies of the Software, and to permit persons to whom the Software is
2690+
furnished to do so, subject to the following conditions:
2691+
2692+
The above copyright notice and this permission notice shall be included in
2693+
all copies or substantial portions of the Software.
2694+
2695+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2696+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2697+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2698+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2699+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2700+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2701+
THE SOFTWARE.
2702+
2703+
=========================================
2704+
END OF editorconfig-core-js NOTICES AND INFORMATION
2705+
26802706
%% gcc-9/libgcc NOTICES AND INFORMATION BEGIN HERE
26812707
=========================================
26822708
The following runtime libraries are licensed under the terms of the

Extension/package.json

+2-3
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.1-main",
5+
"version": "1.23.2-main",
66
"publisher": "ms-vscode",
77
"icon": "LanguageCCPP_color_128x.png",
88
"readme": "README.md",
@@ -6517,7 +6517,6 @@
65176517
"devDependencies": {
65186518
"@octokit/rest": "^20.1.1",
65196519
"@types/glob": "^7.2.0",
6520-
"@types/minimatch": "^3.0.5",
65216520
"@types/mocha": "^10.0.6",
65226521
"@types/node": "^20.14.2",
65236522
"@types/node-fetch": "^2.6.11",
@@ -6569,7 +6568,7 @@
65696568
"comment-json": "^4.2.3",
65706569
"escape-string-regexp": "^2.0.0",
65716570
"glob": "^7.2.3",
6572-
"minimatch": "^3.0.5",
6571+
"minimatch": "^4.2.0",
65736572
"mkdirp": "^3.0.1",
65746573
"node-fetch": "^2.7.0",
65756574
"node-loader": "^2.0.0",

Extension/src/LanguageServer/client.ts

+51-15
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,19 @@ export interface ChatContextResult {
541541
targetArchitecture: string;
542542
}
543543

544+
export interface FileContextResult {
545+
compilerArguments: string[];
546+
}
547+
548+
export interface ProjectContextResult {
549+
language: string;
550+
standardVersion: string;
551+
compiler: string;
552+
targetPlatform: string;
553+
targetArchitecture: string;
554+
fileContext: FileContextResult;
555+
}
556+
544557
// Requests
545558
const PreInitializationRequest: RequestType<void, string, void> = new RequestType<void, string, void>('cpptools/preinitialize');
546559
const InitializationRequest: RequestType<CppInitializationParams, void, void> = new RequestType<CppInitializationParams, void, void>('cpptools/initialize');
@@ -560,7 +573,8 @@ const GoToDirectiveInGroupRequest: RequestType<GoToDirectiveInGroupParams, Posit
560573
const GenerateDoxygenCommentRequest: RequestType<GenerateDoxygenCommentParams, GenerateDoxygenCommentResult | undefined, void> = new RequestType<GenerateDoxygenCommentParams, GenerateDoxygenCommentResult, void>('cpptools/generateDoxygenComment');
561574
const ChangeCppPropertiesRequest: RequestType<CppPropertiesParams, void, void> = new RequestType<CppPropertiesParams, void, void>('cpptools/didChangeCppProperties');
562575
const IncludesRequest: RequestType<GetIncludesParams, GetIncludesResult, void> = new RequestType<GetIncludesParams, GetIncludesResult, void>('cpptools/getIncludes');
563-
const CppContextRequest: RequestType<void, ChatContextResult, void> = new RequestType<void, ChatContextResult, void>('cpptools/getChatContext');
576+
const CppContextRequest: RequestType<TextDocumentIdentifier, ChatContextResult, void> = new RequestType<TextDocumentIdentifier, ChatContextResult, void>('cpptools/getChatContext');
577+
const ProjectContextRequest: RequestType<TextDocumentIdentifier, ProjectContextResult, void> = new RequestType<TextDocumentIdentifier, ProjectContextResult, void>('cpptools/getProjectContext');
564578

565579
// Notifications to the server
566580
const DidOpenNotification: NotificationType<DidOpenTextDocumentParams> = new NotificationType<DidOpenTextDocumentParams>('textDocument/didOpen');
@@ -762,7 +776,7 @@ export interface Client {
762776
PauseCodeAnalysis(): void;
763777
ResumeCodeAnalysis(): void;
764778
CancelCodeAnalysis(): void;
765-
handleConfigurationSelectCommand(): Promise<void>;
779+
handleConfigurationSelectCommand(config?: string): Promise<void>;
766780
handleConfigurationProviderSelectCommand(): Promise<void>;
767781
handleShowActiveCodeAnalysisCommands(): Promise<void>;
768782
handleShowIdleCodeAnalysisCommands(): Promise<void>;
@@ -790,8 +804,9 @@ export interface Client {
790804
getShowConfigureIntelliSenseButton(): boolean;
791805
setShowConfigureIntelliSenseButton(show: boolean): void;
792806
addTrustedCompiler(path: string): Promise<void>;
793-
getIncludes(maxDepth: number, token: vscode.CancellationToken): Promise<GetIncludesResult>;
794-
getChatContext(token: vscode.CancellationToken): Promise<ChatContextResult>;
807+
getIncludes(maxDepth: number): Promise<GetIncludesResult>;
808+
getChatContext(uri: vscode.Uri, token: vscode.CancellationToken): Promise<ChatContextResult>;
809+
getProjectContext(uri: vscode.Uri): Promise<ProjectContextResult>;
795810
}
796811

797812
export function createClient(workspaceFolder?: vscode.WorkspaceFolder): Client {
@@ -1285,6 +1300,12 @@ export class DefaultClient implements Client {
12851300

12861301
// Listen for messages from the language server.
12871302
this.registerNotifications();
1303+
1304+
// If a file is already open when we activate, sometimes we don't get any notifications about visible
1305+
// or active text editors, visible ranges, or text selection. As a workaround, we trigger
1306+
// onDidChangeVisibleTextEditors here.
1307+
const cppEditors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => util.isCpp(e.document));
1308+
await this.onDidChangeVisibleTextEditors(cppEditors);
12881309
}
12891310

12901311
// update all client configurations
@@ -2207,17 +2228,31 @@ export class DefaultClient implements Client {
22072228
await this.languageClient.sendNotification(DidOpenNotification, params);
22082229
}
22092230

2210-
public async getIncludes(maxDepth: number, token: vscode.CancellationToken): Promise<GetIncludesResult> {
2231+
/**
2232+
* Copilot completion-related requests (e.g. getIncludes and getProjectContext) will have their cancellation tokens cancelled
2233+
* if the current request times out (showing the user completion results without context info),
2234+
* but the results can still be used for future requests (due to caching) so it's better to return results instead of cancelling.
2235+
* This is different behavior from the getChatContext, which does handle cancel requests, since the request blocks
2236+
* the UI results and always re-requests (no caching).
2237+
*/
2238+
2239+
public async getIncludes(maxDepth: number): Promise<GetIncludesResult> {
22112240
const params: GetIncludesParams = { maxDepth: maxDepth };
22122241
await this.ready;
2213-
return DefaultClient.withLspCancellationHandling(
2214-
() => this.languageClient.sendRequest(IncludesRequest, params, token), token);
2242+
return this.languageClient.sendRequest(IncludesRequest, params);
22152243
}
22162244

2217-
public async getChatContext(token: vscode.CancellationToken): Promise<ChatContextResult> {
2245+
public async getProjectContext(uri: vscode.Uri): Promise<ProjectContextResult> {
2246+
const params: TextDocumentIdentifier = { uri: uri.toString() };
2247+
await this.ready;
2248+
return this.languageClient.sendRequest(ProjectContextRequest, params);
2249+
}
2250+
2251+
public async getChatContext(uri: vscode.Uri, token: vscode.CancellationToken): Promise<ChatContextResult> {
2252+
const params: TextDocumentIdentifier = { uri: uri.toString() };
22182253
await withCancellation(this.ready, token);
22192254
return DefaultClient.withLspCancellationHandling(
2220-
() => this.languageClient.sendRequest(CppContextRequest, null, token), token);
2255+
() => this.languageClient.sendRequest(CppContextRequest, params, token), token);
22212256
}
22222257

22232258
/**
@@ -2311,7 +2346,6 @@ export class DefaultClient implements Client {
23112346
throw e;
23122347
}
23132348
}
2314-
23152349
if (token.isCancellationRequested) {
23162350
throw new vscode.CancellationError();
23172351
}
@@ -2571,7 +2605,8 @@ export class DefaultClient implements Client {
25712605
}
25722606
let foundGlobMatch: boolean = false;
25732607
for (const assoc in assocs) {
2574-
if (minimatch(filePath, assoc)) {
2608+
const matcher = new minimatch.Minimatch(assoc);
2609+
if (matcher.match(filePath)) {
25752610
foundGlobMatch = true;
25762611
break; // Assoc matched a glob pattern.
25772612
}
@@ -3241,11 +3276,11 @@ export class DefaultClient implements Client {
32413276
/**
32423277
* command handlers
32433278
*/
3244-
public async handleConfigurationSelectCommand(): Promise<void> {
3279+
public async handleConfigurationSelectCommand(config?: string): Promise<void> {
32453280
await this.ready;
32463281
const configNames: string[] | undefined = this.configuration.ConfigurationNames;
32473282
if (configNames) {
3248-
const index: number = await ui.showConfigurations(configNames);
3283+
const index: number = config ? configNames.indexOf(config) : await ui.showConfigurations(configNames);
32493284
if (index < 0) {
32503285
return;
32513286
}
@@ -4121,6 +4156,7 @@ class NullClient implements Client {
41214156
getShowConfigureIntelliSenseButton(): boolean { return false; }
41224157
setShowConfigureIntelliSenseButton(show: boolean): void { }
41234158
addTrustedCompiler(path: string): Promise<void> { return Promise.resolve(); }
4124-
getIncludes(maxDepth: number, token: vscode.CancellationToken): Promise<GetIncludesResult> { return Promise.resolve({} as GetIncludesResult); }
4125-
getChatContext(token: vscode.CancellationToken): Promise<ChatContextResult> { return Promise.resolve({} as ChatContextResult); }
4159+
getIncludes(maxDepth: number): Promise<GetIncludesResult> { return Promise.resolve({} as GetIncludesResult); }
4160+
getChatContext(uri: vscode.Uri, token: vscode.CancellationToken): Promise<ChatContextResult> { return Promise.resolve({} as ChatContextResult); }
4161+
getProjectContext(uri: vscode.Uri): Promise<ProjectContextResult> { return Promise.resolve({} as ProjectContextResult); }
41264162
}

Extension/src/LanguageServer/configurations.ts

+32-5
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class CppProperties {
138138
private configFileWatcherFallbackTime: Date = new Date(); // Used when file watching fails.
139139
private compileCommandsFile: vscode.Uri | undefined | null = undefined;
140140
private compileCommandsFileWatchers: fs.FSWatcher[] = [];
141-
private compileCommandsFileWatcherFallbackTime: Date = new Date(); // Used when file watching fails.
141+
private compileCommandsFileWatcherFallbackTime: Map<string, Date> = new Map<string, Date>(); // Used when file watching fails.
142142
private defaultCompilerPath: string | null = null;
143143
private knownCompilers?: KnownCompiler[];
144144
private defaultCStandard: string | null = null;
@@ -1093,6 +1093,10 @@ export class CppProperties {
10931093

10941094
if (configuration.compileCommands) {
10951095
configuration.compileCommands = this.resolvePath(configuration.compileCommands);
1096+
if (!this.compileCommandsFileWatcherFallbackTime.has(configuration.compileCommands)) {
1097+
// Start tracking the fallback time for a new path.
1098+
this.compileCommandsFileWatcherFallbackTime.set(configuration.compileCommands, new Date());
1099+
}
10961100
}
10971101

10981102
if (configuration.forcedInclude) {
@@ -1104,12 +1108,31 @@ export class CppProperties {
11041108
}
11051109
}
11061110

1111+
this.clearStaleCompileCommandsFileWatcherFallbackTimes();
11071112
this.updateCompileCommandsFileWatchers();
11081113
if (!this.configurationIncomplete) {
11091114
this.onConfigurationsChanged();
11101115
}
11111116
}
11121117

1118+
private clearStaleCompileCommandsFileWatcherFallbackTimes(): void {
1119+
// We need to keep track of relevant timestamps, so we cannot simply clear all entries.
1120+
// Instead, we clear entries that are no longer relevant.
1121+
const trackedCompileCommandsPaths: Set<string> = new Set();
1122+
this.configurationJson?.configurations.forEach((config: Configuration) => {
1123+
const path = this.resolvePath(config.compileCommands);
1124+
if (path.length > 0) {
1125+
trackedCompileCommandsPaths.add(path);
1126+
}
1127+
});
1128+
1129+
for (const path of this.compileCommandsFileWatcherFallbackTime.keys()) {
1130+
if (!trackedCompileCommandsPaths.has(path)) {
1131+
this.compileCommandsFileWatcherFallbackTime.delete(path);
1132+
}
1133+
}
1134+
}
1135+
11131136
private compileCommandsFileWatcherTimer?: NodeJS.Timeout;
11141137
private compileCommandsFileWatcherFiles: Set<string> = new Set<string>();
11151138

@@ -2310,14 +2333,18 @@ export class CppProperties {
23102333
fs.stat(compileCommandsFile, (err, stats) => {
23112334
if (err) {
23122335
if (err.code === "ENOENT" && this.compileCommandsFile) {
2336+
this.compileCommandsFileWatchers.forEach((watcher: fs.FSWatcher) => watcher.close());
23132337
this.compileCommandsFileWatchers = []; // reset file watchers
23142338
this.onCompileCommandsChanged(compileCommandsFile);
23152339
this.compileCommandsFile = null; // File deleted
23162340
}
2317-
} else if (stats.mtime > this.compileCommandsFileWatcherFallbackTime) {
2318-
this.compileCommandsFileWatcherFallbackTime = new Date();
2319-
this.onCompileCommandsChanged(compileCommandsFile);
2320-
this.compileCommandsFile = vscode.Uri.file(compileCommandsFile); // File created.
2341+
} else {
2342+
const compileCommandsLastChanged: Date | undefined = this.compileCommandsFileWatcherFallbackTime.get(compileCommandsFile);
2343+
if (compileCommandsLastChanged !== undefined && stats.mtime > compileCommandsLastChanged) {
2344+
this.compileCommandsFileWatcherFallbackTime.set(compileCommandsFile, new Date());
2345+
this.onCompileCommandsChanged(compileCommandsFile);
2346+
this.compileCommandsFile = vscode.Uri.file(compileCommandsFile); // File created.
2347+
}
23212348
}
23222349
});
23232350
}

0 commit comments

Comments
 (0)