Skip to content

Commit

Permalink
Merge pull request #13021 from microsoft/main
Browse files Browse the repository at this point in the history
Merge to insiders for 1.23.2
  • Loading branch information
sean-mcmanus authored Dec 5, 2024
2 parents 784f145 + 44b736e commit 99d98af
Show file tree
Hide file tree
Showing 18 changed files with 1,087 additions and 192 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
job:
uses: ./.github/workflows/job-compile-and-test.yml
with:
runner-env: macos-12
runner-env: macos-14
platform: mac
yarn-args: --network-timeout 100000
8 changes: 8 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @microsoft/cpptools-maintainers will be requested for
# review when someone opens a pull request.

* @microsoft/cpptools-maintainers
22 changes: 22 additions & 0 deletions Extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# C/C++ for Visual Studio Code Changelog

### Version 1.23.2: December 5, 2024
### Enhancements
* Add handling of `-fno-char8_t` and `-fchar8_t` compiler arguments. [#12968](https://github.com/microsoft/vscode-cpptools/issues/12968)
* Add support for providing well-known compiler argument information to Copilot Completions. [PR #12979](https://github.com/microsoft/vscode-cpptools/pull/12979)
* Fixed unnecessary cancellation of Copilot context requests. [PR #12988](https://github.com/microsoft/vscode-cpptools/pull/12988)
* Add support for passing an additional parameter to `C_Cpp.ConfigurationSelect` command. [PR #12993](https://github.com/microsoft/vscode-cpptools/pull/12993)
* Thank you for the contribution. [@adrianstephens](https://github.com/adrianstephens)
* Update clang-format and clang-tidy from 19.1.2 to 19.1.5.
* Changes to how paths are internally canonicalized on Linux and macOS, avoiding file system access to improve performance and delay resolution of symbolic links.

### Bug Fixes
* Increase clang-format timeout from 10 seconds to 30 seconds. [#10213](https://github.com/microsoft/vscode-cpptools/issues/10213)
* Fix casing of path in include completion tooltip on Windows. [#12895](https://github.com/microsoft/vscode-cpptools/issues/12895)
* Fix pattern matching of sections in `.editorConfig` files. [#12933](https://github.com/microsoft/vscode-cpptools/issues/12933)
* Fix handling of relative paths passed to cl.exe `/reference` argument. [#12944](https://github.com/microsoft/vscode-cpptools/issues/12944)
* Fix a leak of compile command file watchers. [#12946](https://github.com/microsoft/vscode-cpptools/issues/12946)
* Thank you for the contribution. [@yiftahw](https://github.com/yiftahw) [PR #12948](https://github.com/microsoft/vscode-cpptools/pull/12948)
* Fix a compile commands fallback logic issue. [#12947](https://github.com/microsoft/vscode-cpptools/issues/12947)
* Thank you for the contribution. [@yiftahw](https://github.com/yiftahw) [PR #12948](https://github.com/microsoft/vscode-cpptools/pull/12948)
* 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)
* Fix IntelliSense issues related to large header files (>32K) and encodings other than UTF-8.

### Version 1.23.1: November 6, 2024
### Bug Fixes
* A potential fix for a crash during process shutdown (in `uv_run`). [#12668](https://github.com/microsoft/vscode-cpptools/issues/12668)
Expand Down
26 changes: 26 additions & 0 deletions Extension/ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,7 @@ The notices below are from non-npm sources.
- ANTLR (http://www.antlr2.org/)
- C++11 Sublime Text Snippets (https://github.com/Rapptz/cpp-sublime-snippet)
- Clang (https://clang.llvm.org/)
- editorconfig-core-js (https://github.com/editorconfig/editorconfig-core-js)
- gcc-11/libgcc (https://packages.ubuntu.com/jammy/gcc-11-base)
- Guidelines Support Library (https://github.com/Microsoft/GSL)
- libc++ (https://libcxx.llvm.org/index.html)
Expand Down Expand Up @@ -2677,6 +2678,31 @@ mechanisms:
=========================================
END OF Clang NOTICES AND INFORMATION

%% editorconfig-core-js NOTICES AND INFORMATION BEGIN HERE
=========================================
Copyright © 2012 EditorConfig Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

=========================================
END OF editorconfig-core-js NOTICES AND INFORMATION

%% gcc-9/libgcc NOTICES AND INFORMATION BEGIN HERE
=========================================
The following runtime libraries are licensed under the terms of the
Expand Down
5 changes: 2 additions & 3 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cpptools",
"displayName": "C/C++",
"description": "C/C++ IntelliSense, debugging, and code browsing.",
"version": "1.23.1-main",
"version": "1.23.2-main",
"publisher": "ms-vscode",
"icon": "LanguageCCPP_color_128x.png",
"readme": "README.md",
Expand Down Expand Up @@ -6517,7 +6517,6 @@
"devDependencies": {
"@octokit/rest": "^20.1.1",
"@types/glob": "^7.2.0",
"@types/minimatch": "^3.0.5",
"@types/mocha": "^10.0.6",
"@types/node": "^20.14.2",
"@types/node-fetch": "^2.6.11",
Expand Down Expand Up @@ -6569,7 +6568,7 @@
"comment-json": "^4.2.3",
"escape-string-regexp": "^2.0.0",
"glob": "^7.2.3",
"minimatch": "^3.0.5",
"minimatch": "^4.2.0",
"mkdirp": "^3.0.1",
"node-fetch": "^2.7.0",
"node-loader": "^2.0.0",
Expand Down
66 changes: 51 additions & 15 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,19 @@ export interface ChatContextResult {
targetArchitecture: string;
}

export interface FileContextResult {
compilerArguments: string[];
}

export interface ProjectContextResult {
language: string;
standardVersion: string;
compiler: string;
targetPlatform: string;
targetArchitecture: string;
fileContext: FileContextResult;
}

// Requests
const PreInitializationRequest: RequestType<void, string, void> = new RequestType<void, string, void>('cpptools/preinitialize');
const InitializationRequest: RequestType<CppInitializationParams, void, void> = new RequestType<CppInitializationParams, void, void>('cpptools/initialize');
Expand All @@ -560,7 +573,8 @@ const GoToDirectiveInGroupRequest: RequestType<GoToDirectiveInGroupParams, Posit
const GenerateDoxygenCommentRequest: RequestType<GenerateDoxygenCommentParams, GenerateDoxygenCommentResult | undefined, void> = new RequestType<GenerateDoxygenCommentParams, GenerateDoxygenCommentResult, void>('cpptools/generateDoxygenComment');
const ChangeCppPropertiesRequest: RequestType<CppPropertiesParams, void, void> = new RequestType<CppPropertiesParams, void, void>('cpptools/didChangeCppProperties');
const IncludesRequest: RequestType<GetIncludesParams, GetIncludesResult, void> = new RequestType<GetIncludesParams, GetIncludesResult, void>('cpptools/getIncludes');
const CppContextRequest: RequestType<void, ChatContextResult, void> = new RequestType<void, ChatContextResult, void>('cpptools/getChatContext');
const CppContextRequest: RequestType<TextDocumentIdentifier, ChatContextResult, void> = new RequestType<TextDocumentIdentifier, ChatContextResult, void>('cpptools/getChatContext');
const ProjectContextRequest: RequestType<TextDocumentIdentifier, ProjectContextResult, void> = new RequestType<TextDocumentIdentifier, ProjectContextResult, void>('cpptools/getProjectContext');

// Notifications to the server
const DidOpenNotification: NotificationType<DidOpenTextDocumentParams> = new NotificationType<DidOpenTextDocumentParams>('textDocument/didOpen');
Expand Down Expand Up @@ -762,7 +776,7 @@ export interface Client {
PauseCodeAnalysis(): void;
ResumeCodeAnalysis(): void;
CancelCodeAnalysis(): void;
handleConfigurationSelectCommand(): Promise<void>;
handleConfigurationSelectCommand(config?: string): Promise<void>;
handleConfigurationProviderSelectCommand(): Promise<void>;
handleShowActiveCodeAnalysisCommands(): Promise<void>;
handleShowIdleCodeAnalysisCommands(): Promise<void>;
Expand Down Expand Up @@ -790,8 +804,9 @@ export interface Client {
getShowConfigureIntelliSenseButton(): boolean;
setShowConfigureIntelliSenseButton(show: boolean): void;
addTrustedCompiler(path: string): Promise<void>;
getIncludes(maxDepth: number, token: vscode.CancellationToken): Promise<GetIncludesResult>;
getChatContext(token: vscode.CancellationToken): Promise<ChatContextResult>;
getIncludes(maxDepth: number): Promise<GetIncludesResult>;
getChatContext(uri: vscode.Uri, token: vscode.CancellationToken): Promise<ChatContextResult>;
getProjectContext(uri: vscode.Uri): Promise<ProjectContextResult>;
}

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

// Listen for messages from the language server.
this.registerNotifications();

// If a file is already open when we activate, sometimes we don't get any notifications about visible
// or active text editors, visible ranges, or text selection. As a workaround, we trigger
// onDidChangeVisibleTextEditors here.
const cppEditors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => util.isCpp(e.document));
await this.onDidChangeVisibleTextEditors(cppEditors);
}

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

public async getIncludes(maxDepth: number, token: vscode.CancellationToken): Promise<GetIncludesResult> {
/**
* Copilot completion-related requests (e.g. getIncludes and getProjectContext) will have their cancellation tokens cancelled
* if the current request times out (showing the user completion results without context info),
* but the results can still be used for future requests (due to caching) so it's better to return results instead of cancelling.
* This is different behavior from the getChatContext, which does handle cancel requests, since the request blocks
* the UI results and always re-requests (no caching).
*/

public async getIncludes(maxDepth: number): Promise<GetIncludesResult> {
const params: GetIncludesParams = { maxDepth: maxDepth };
await this.ready;
return DefaultClient.withLspCancellationHandling(
() => this.languageClient.sendRequest(IncludesRequest, params, token), token);
return this.languageClient.sendRequest(IncludesRequest, params);
}

public async getChatContext(token: vscode.CancellationToken): Promise<ChatContextResult> {
public async getProjectContext(uri: vscode.Uri): Promise<ProjectContextResult> {
const params: TextDocumentIdentifier = { uri: uri.toString() };
await this.ready;
return this.languageClient.sendRequest(ProjectContextRequest, params);
}

public async getChatContext(uri: vscode.Uri, token: vscode.CancellationToken): Promise<ChatContextResult> {
const params: TextDocumentIdentifier = { uri: uri.toString() };
await withCancellation(this.ready, token);
return DefaultClient.withLspCancellationHandling(
() => this.languageClient.sendRequest(CppContextRequest, null, token), token);
() => this.languageClient.sendRequest(CppContextRequest, params, token), token);
}

/**
Expand Down Expand Up @@ -2311,7 +2346,6 @@ export class DefaultClient implements Client {
throw e;
}
}

if (token.isCancellationRequested) {
throw new vscode.CancellationError();
}
Expand Down Expand Up @@ -2571,7 +2605,8 @@ export class DefaultClient implements Client {
}
let foundGlobMatch: boolean = false;
for (const assoc in assocs) {
if (minimatch(filePath, assoc)) {
const matcher = new minimatch.Minimatch(assoc);
if (matcher.match(filePath)) {
foundGlobMatch = true;
break; // Assoc matched a glob pattern.
}
Expand Down Expand Up @@ -3241,11 +3276,11 @@ export class DefaultClient implements Client {
/**
* command handlers
*/
public async handleConfigurationSelectCommand(): Promise<void> {
public async handleConfigurationSelectCommand(config?: string): Promise<void> {
await this.ready;
const configNames: string[] | undefined = this.configuration.ConfigurationNames;
if (configNames) {
const index: number = await ui.showConfigurations(configNames);
const index: number = config ? configNames.indexOf(config) : await ui.showConfigurations(configNames);
if (index < 0) {
return;
}
Expand Down Expand Up @@ -4121,6 +4156,7 @@ class NullClient implements Client {
getShowConfigureIntelliSenseButton(): boolean { return false; }
setShowConfigureIntelliSenseButton(show: boolean): void { }
addTrustedCompiler(path: string): Promise<void> { return Promise.resolve(); }
getIncludes(maxDepth: number, token: vscode.CancellationToken): Promise<GetIncludesResult> { return Promise.resolve({} as GetIncludesResult); }
getChatContext(token: vscode.CancellationToken): Promise<ChatContextResult> { return Promise.resolve({} as ChatContextResult); }
getIncludes(maxDepth: number): Promise<GetIncludesResult> { return Promise.resolve({} as GetIncludesResult); }
getChatContext(uri: vscode.Uri, token: vscode.CancellationToken): Promise<ChatContextResult> { return Promise.resolve({} as ChatContextResult); }
getProjectContext(uri: vscode.Uri): Promise<ProjectContextResult> { return Promise.resolve({} as ProjectContextResult); }
}
37 changes: 32 additions & 5 deletions Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class CppProperties {
private configFileWatcherFallbackTime: Date = new Date(); // Used when file watching fails.
private compileCommandsFile: vscode.Uri | undefined | null = undefined;
private compileCommandsFileWatchers: fs.FSWatcher[] = [];
private compileCommandsFileWatcherFallbackTime: Date = new Date(); // Used when file watching fails.
private compileCommandsFileWatcherFallbackTime: Map<string, Date> = new Map<string, Date>(); // Used when file watching fails.
private defaultCompilerPath: string | null = null;
private knownCompilers?: KnownCompiler[];
private defaultCStandard: string | null = null;
Expand Down Expand Up @@ -1093,6 +1093,10 @@ export class CppProperties {

if (configuration.compileCommands) {
configuration.compileCommands = this.resolvePath(configuration.compileCommands);
if (!this.compileCommandsFileWatcherFallbackTime.has(configuration.compileCommands)) {
// Start tracking the fallback time for a new path.
this.compileCommandsFileWatcherFallbackTime.set(configuration.compileCommands, new Date());
}
}

if (configuration.forcedInclude) {
Expand All @@ -1104,12 +1108,31 @@ export class CppProperties {
}
}

this.clearStaleCompileCommandsFileWatcherFallbackTimes();
this.updateCompileCommandsFileWatchers();
if (!this.configurationIncomplete) {
this.onConfigurationsChanged();
}
}

private clearStaleCompileCommandsFileWatcherFallbackTimes(): void {
// We need to keep track of relevant timestamps, so we cannot simply clear all entries.
// Instead, we clear entries that are no longer relevant.
const trackedCompileCommandsPaths: Set<string> = new Set();
this.configurationJson?.configurations.forEach((config: Configuration) => {
const path = this.resolvePath(config.compileCommands);
if (path.length > 0) {
trackedCompileCommandsPaths.add(path);
}
});

for (const path of this.compileCommandsFileWatcherFallbackTime.keys()) {
if (!trackedCompileCommandsPaths.has(path)) {
this.compileCommandsFileWatcherFallbackTime.delete(path);
}
}
}

private compileCommandsFileWatcherTimer?: NodeJS.Timeout;
private compileCommandsFileWatcherFiles: Set<string> = new Set<string>();

Expand Down Expand Up @@ -2310,14 +2333,18 @@ export class CppProperties {
fs.stat(compileCommandsFile, (err, stats) => {
if (err) {
if (err.code === "ENOENT" && this.compileCommandsFile) {
this.compileCommandsFileWatchers.forEach((watcher: fs.FSWatcher) => watcher.close());
this.compileCommandsFileWatchers = []; // reset file watchers
this.onCompileCommandsChanged(compileCommandsFile);
this.compileCommandsFile = null; // File deleted
}
} else if (stats.mtime > this.compileCommandsFileWatcherFallbackTime) {
this.compileCommandsFileWatcherFallbackTime = new Date();
this.onCompileCommandsChanged(compileCommandsFile);
this.compileCommandsFile = vscode.Uri.file(compileCommandsFile); // File created.
} else {
const compileCommandsLastChanged: Date | undefined = this.compileCommandsFileWatcherFallbackTime.get(compileCommandsFile);
if (compileCommandsLastChanged !== undefined && stats.mtime > compileCommandsLastChanged) {
this.compileCommandsFileWatcherFallbackTime.set(compileCommandsFile, new Date());
this.onCompileCommandsChanged(compileCommandsFile);
this.compileCommandsFile = vscode.Uri.file(compileCommandsFile); // File created.
}
}
});
}
Expand Down
Loading

0 comments on commit 99d98af

Please sign in to comment.