Skip to content

Implement per-workspace C/C++ configurations (#14363)#14366

Closed
Subham-KRLX wants to merge 4 commits intomicrosoft:mainfrom
Subham-KRLX:feature/workspace-configurations
Closed

Implement per-workspace C/C++ configurations (#14363)#14366
Subham-KRLX wants to merge 4 commits intomicrosoft:mainfrom
Subham-KRLX:feature/workspace-configurations

Conversation

@Subham-KRLX
Copy link
Copy Markdown
Contributor

This PR introduces the C_Cpp.configurations setting, allowing users to define C/C++ configurations directly within VS Code workspace or folder settings. This resolves #14363, where multiple workspaces sharing the same folder were forced to share a single c_cpp_properties.json file.

Key Changes

  • Precedence Logic: Updated the configuration parser to prioritize C_Cpp.configurations from settings over the local c_cpp_properties.json file.
  • Full Parity: The new settings-based configurations support the exact same schema, variable resolution (e.g., ${workspaceFolder}), and sanitization logic as the traditional file-based approach.
  • Reactive Updates: Integrated with onDidChangeSettings to ensure IntelliSense/Status Bar UI updates immediately when settings are modified.
  • Backward Compatibility: If the new setting is not present, the extension falls back to existing file-based behavior with no disruption.

Verification

  • Verified that workspace settings override local c_cpp_properties.json.
  • Verified fallback behavior when settings are cleared.
  • Confirmed that variable resolution remains consistent across both configuration sources.

Fixes #14363

@Subham-KRLX Subham-KRLX requested a review from a team as a code owner April 12, 2026 13:14
@github-project-automation github-project-automation Bot moved this to Pull Request in cpptools Apr 12, 2026
"configurations": [
{
"name": "(gdb) Launch",
"preLaunchTask": "build",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Subham-KRLX Can you revert the Code Samples folder changes?

const readResults: string = fs.readFileSync(this.propertiesFile.fsPath, 'utf8');
if (readResults === "") {
return false; // Repros randomly when the file is initially created. The parse will get called again after the file is written.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a "try" removed above, but the catch doesn't appear to be removed. That seems to cause a bunch of compiler errors.

Comment thread Extension/package.json
},
"C_Cpp.configurations": {
"type": "array",
"description": "A list of configurations that will be used instead of c_cpp_properties.json when present in workspace settings.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reference localizable strings, e.g. %c_cpp.configuration.default.recursiveIncludes.order.markdownDescription% in package.nls.json? Or did you want us to do that?

Copy link
Copy Markdown
Contributor

@sean-mcmanus sean-mcmanus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After feedback from Bob, this PR appears unnecessary, and the current design is sufficient via using additional configurations with different names corresponding to which workspace is being used.

@heartacker
Copy link
Copy Markdown
Contributor

how

@sean-mcmanus
Copy link
Copy Markdown
Contributor

how

@heartacker What are you asking exactly? I added a longer comment in the original issue.

@Subham-KRLX Subham-KRLX deleted the feature/workspace-configurations branch April 16, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pull Request

Development

Successfully merging this pull request may close these issues.

There is no way to set c_cpp_properties.json (with multiple configurations) per-workspace

3 participants