Skip to content

Merge to vs #12927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# C/C++ for Visual Studio Code Changelog

## Version 1.23.0: October 29, 2024
### Enhancements
* Update to clang-format and clang-tidy 19.1.2. [#12824](https://github.com/microsoft/vscode-cpptools/issues/12824)
* Enable `#cpp` with GitHub Copilot chat without `C_Cpp.experimentalFeatures` enabled. [PR #12898](https://github.com/microsoft/vscode-cpptools/pull/12898)

### Bug Fixes
* 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)
* Fix a bug with 'Select IntelliSense Configuration'. [#12705](https://github.com/microsoft/vscode-cpptools/issues/12705)
* Fix newlines being removed from hover markdown code blocks. [#12794](https://github.com/microsoft/vscode-cpptools/issues/12794)
* Fix clang-format using `-` instead of `--` args. [#12819](https://github.com/microsoft/vscode-cpptools/issues/12819)
* Fix processing of `compile_commands.json` generated by the clang `-MJ` option. [#12837](https://github.com/microsoft/vscode-cpptools/issues/12837)
* Fix handling of `-I` and `-isystem` with the same path. [#12842](https://github.com/microsoft/vscode-cpptools/issues/12842)
* Fix stale colorization due to delays in updating the open file version. [PR #12851](https://github.com/microsoft/vscode-cpptools/pull/12851)
* Fix redundant progressive squiggle updates. [PR #12876](https://github.com/microsoft/vscode-cpptools/pull/12876)
* Fix inactive regions with multi-byte UTF-8 characters. [#12879](https://github.com/microsoft/vscode-cpptools/issues/12879)
* Fix some duplicate requests potentially not getting discarded.
* Fix a random crash in `start_process_and_wait_for_exit`.

## Version 1.22.10: October 21, 2024
### Bug Fixes
* Fix the 'Extract to Function' feature not working.
* Fix the 'Go to Next/Prev Preprocessor Conditional' feature not working.

## Version 1.22.9: October 10, 2024
## Version 1.22.9: October 14, 2024
### Performance Improvements
* Initialization performance improvements. [#12030](https://github.com/microsoft/vscode-cpptools/issues/12030)
- 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)
Expand Down
7 changes: 3 additions & 4 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.22.9-main",
"version": "1.23.0-main",
"publisher": "ms-vscode",
"icon": "LanguageCCPP_color_128x.png",
"readme": "README.md",
Expand Down Expand Up @@ -38,8 +38,7 @@
"Snippets"
],
"enabledApiProposals": [
"terminalDataWriteEvent",
"lmTools"
"terminalDataWriteEvent"
],
"capabilities": {
"untrustedWorkspaces": {
Expand Down Expand Up @@ -6512,7 +6511,7 @@
"translations-generate": "set NODE_OPTIONS=--no-experimental-fetch && gulp translations-generate",
"translations-import": "gulp translations-import",
"import-edge-strings": "ts-node -T ./.scripts/import_edge_strings.ts",
"prep:dts": "yarn verify dts --quiet || (npx vscode-dts dev && npx vscode-dts main)",
"prep:dts": "yarn verify dts --quiet || (npx @vscode/dts dev && npx @vscode/dts main)",
"build": "yarn prep:dts && echo [Building TypeScript code] && tsc --build tsconfig.json"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/Debugger/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv

// Run deploy steps
if (config.deploySteps && config.deploySteps.length !== 0) {
const codeVersion: number[] = vscode.version.split('.').map(num => parseInt(num, undefined));
const codeVersion: number[] = util.getVsCodeVersion();
if ((util.isNumber(codeVersion[0]) && codeVersion[0] < 1) || (util.isNumber(codeVersion[0]) && codeVersion[0] === 1 && util.isNumber(codeVersion[1]) && codeVersion[1] < 69)) {
void logger.getOutputChannelLogger().showErrorMessage(localize("vs.code.1.69+.required", "'deploySteps' require VS Code 1.69+."));
return undefined;
Expand Down
13 changes: 8 additions & 5 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ export class DefaultClient implements Client {
if (index === paths.length - 1) {
action = "disable";
settings.defaultCompilerPath = "";
await this.configuration.updateCompilerPathIfSet(settings.defaultCompilerPath);
await this.configuration.updateCompilerPathIfSet("");
configurationSelected = true;
await this.showPrompt(sender);
return ui.ShowConfigureIntelliSenseButton(false, this, ConfigurationType.CompilerPath, "disablePrompt");
Expand All @@ -1066,7 +1066,7 @@ export class DefaultClient implements Client {
configurationSelected = true;
action = "compiler browsed";
settings.defaultCompilerPath = result[0].fsPath;
await this.configuration.updateCompilerPathIfSet(settings.defaultCompilerPath);
await this.configuration.updateCompilerPathIfSet(result[0].fsPath);
void SessionState.trustedCompilerFound.set(true);
} else {
configurationSelected = true;
Expand All @@ -1084,8 +1084,9 @@ export class DefaultClient implements Client {
return ui.ShowConfigureIntelliSenseButton(false, this, ConfigurationType.CompileCommands, showButtonSender);
} else {
action = "select compiler";
settings.defaultCompilerPath = util.isCl(paths[index]) ? "cl.exe" : paths[index];
await this.configuration.updateCompilerPathIfSet(settings.defaultCompilerPath);
const newCompiler: string = util.isCl(paths[index]) ? "cl.exe" : paths[index];
settings.defaultCompilerPath = newCompiler;
await this.configuration.updateCompilerPathIfSet(newCompiler);
void SessionState.trustedCompilerFound.set(true);
}
}
Expand Down Expand Up @@ -2387,7 +2388,9 @@ export class DefaultClient implements Client {
}

this.updateInactiveRegions(intelliSenseResult.uri, intelliSenseResult.inactiveRegions, intelliSenseResult.clearExistingInactiveRegions, intelliSenseResult.isCompletePass);
this.updateSquiggles(intelliSenseResult.uri, intelliSenseResult.diagnostics, intelliSenseResult.clearExistingDiagnostics);
if (intelliSenseResult.clearExistingDiagnostics || intelliSenseResult.diagnostics.length > 0) {
this.updateSquiggles(intelliSenseResult.uri, intelliSenseResult.diagnostics, intelliSenseResult.clearExistingDiagnostics);
}
}

private updateSquiggles(uriString: string, diagnostics: IntelliSenseDiagnostic[], startNewSet: boolean): void {
Expand Down
8 changes: 4 additions & 4 deletions Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ export class CppProperties {
compilerPath = checkPathExists.path;
}
if (!compilerPathExists) {
compilerMessage = localize('cannot.find2', "Cannot find \"{0}\".", compilerPath);
compilerMessage = localize('cannot.find', "Cannot find: {0}", compilerPath);
newSquiggleMetrics.PathNonExistent++;
}
if (compilerMessage) {
Expand All @@ -1975,7 +1975,7 @@ export class CppProperties {
dotConfigPath = checkPathExists.path;
}
if (!dotConfigPathExists) {
dotConfigMessage = localize('cannot.find2', "Cannot find \"{0}\".", dotConfigPath);
dotConfigMessage = localize('cannot.find', "Cannot find: {0}", dotConfigPath);
newSquiggleMetrics.PathNonExistent++;
} else if (dotConfigPath && !util.checkFileExistsSync(dotConfigPath)) {
dotConfigMessage = localize("path.is.not.a.file", "Path is not a file: {0}", dotConfigPath);
Expand Down Expand Up @@ -2083,7 +2083,7 @@ export class CppProperties {
} else {
badPath = `"${expandedPaths[0]}"`;
}
message = localize('cannot.find2', "Cannot find {0}", badPath);
message = localize('cannot.find', "Cannot find: {0}", badPath);
newSquiggleMetrics.PathNonExistent++;
} else {
// Check for file versus path mismatches.
Expand Down Expand Up @@ -2141,7 +2141,7 @@ export class CppProperties {
endOffset = curOffset + curMatch.length;
let message: string;
if (!pathExists) {
message = localize('cannot.find2', "Cannot find \"{0}\".", expandedPaths[0]);
message = localize('cannot.find', "Cannot find: {0}", expandedPaths[0]);
newSquiggleMetrics.PathNonExistent++;
const diagnostic: vscode.Diagnostic = new vscode.Diagnostic(
new vscode.Range(document.positionAt(envTextStartOffSet + curOffset),
Expand Down
16 changes: 13 additions & 3 deletions Extension/src/LanguageServer/editorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,17 @@ function parseEditorConfigContent(content: string): Record<string, any> {
const [key, ...values] = line.split('=');
if (key && values.length > 0) {
const trimmedKey = key.trim();
const value = values.join('=').trim();
let value: any = values.join('=').trim();

// Convert boolean-like and numeric values.
if (value.toLowerCase() === 'true') {
value = true;
} else if (value.toLowerCase() === 'false') {
value = false;
} else if (!isNaN(Number(value))) {
value = Number(value);
}

if (currentSection) {
// Ensure the current section is initialized.
if (!config[currentSection]) {
Expand All @@ -114,7 +124,7 @@ function getEditorConfig(filePath: string): any {
const rootDir: string = path.parse(currentDir).root;

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

// Check if the current .editorconfig is the root.
if (configData['*']?.root?.toLowerCase() === 'true') {
if (configData['*']?.root) {
break; // Stop searching after processing the root = true file.
}
}
Expand Down
12 changes: 9 additions & 3 deletions Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,15 @@ export async function activate(): Promise<void> {
activeDocument = activeEditor.document;
}

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

await registerRelatedFilesProvider();
Expand Down
41 changes: 29 additions & 12 deletions Extension/src/LanguageServer/lmTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
}

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

telemetry.logLanguageModelToolEvent(
'cpp',
{
"language": chatContext.language,
"compiler": chatContext.compiler,
"standardVersion": chatContext.standardVersion,
"targetPlatform": chatContext.targetPlatform,
"targetArchitecture": chatContext.targetArchitecture
});

for (const key in knownValues) {
const knownKey = key as keyof ChatContextResult;
if (knownValues[knownKey] && chatContext[knownKey]) {
chatContext[knownKey] = knownValues[knownKey][chatContext[knownKey]] || chatContext[knownKey];
// Clear the value if it's not in the known values.
chatContext[knownKey] = knownValues[knownKey][chatContext[knownKey]] || "";
}
}

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.`;
let contextString = "";
if (chatContext.language) {
contextString += `The user is working on a ${chatContext.language} project. `;
telemetryProperties["language"] = chatContext.language;
}
if (chatContext.standardVersion) {
contextString += `The project uses language version ${chatContext.standardVersion}. `;
telemetryProperties["standardVersion"] = chatContext.standardVersion;
}
if (chatContext.compiler) {
contextString += `The project compiles using the ${chatContext.compiler} compiler. `;
telemetryProperties["compiler"] = chatContext.compiler;
}
if (chatContext.targetPlatform) {
contextString += `The project targets the ${chatContext.targetPlatform} platform. `;
telemetryProperties["targetPlatform"] = chatContext.targetPlatform;
}
if (chatContext.targetArchitecture) {
contextString += `The project targets the ${chatContext.targetArchitecture} architecture. `;
telemetryProperties["targetArchitecture"] = chatContext.targetArchitecture;
}

return contextString;
}
catch {
await this.reportError();
telemetryProperties["error"] = "true";
return "";
} finally {
telemetry.logLanguageModelToolEvent('cpp', telemetryProperties);
}
}

Expand Down
Loading
Loading