Skip to content
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

Don't merge all the compileCommandFragments for the browse path #2754

Merged
merged 1 commit into from
Sep 26, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Improvements:
- Preset in CMakeUserPresets.json using "condition" does not appear in configure preset selection. [#2749](https://github.com/microsoft/vscode-cmake-tools/issues/2749)
- Resolve workspace variables in `cmake-kits.json`. [#2737](https://github.com/microsoft/vscode-cmake-tools/issues/2737)
- Use upper case drive letters on Windows for `cmake.sourceDirectory`. [PR #2665](https://github.com/microsoft/vscode-cmake-tools/pull/2665) [@Danielmelody](https://github.com/Danielmelody)
- Custom browse configuration should not include (redundant) per-file arguments. [#2645](https://github.com/microsoft/vscode-cmake-tools/issues/2645)

## 1.12.27
Bug Fixes:
Expand Down
2 changes: 1 addition & 1 deletion src/cpptools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro
// 3. Any `fileGroup` that does not have the associated attribute will receive the `default`
const grps = target.fileGroups || [];
const includePath = [...new Set(util.flatMap(grps, grp => grp.includePath || []))].map(item => item.path);
const compileCommandFragments = [...util.flatMap(grps, grp => grp.compileCommandFragments || [])];
const compileCommandFragments = [...util.first(grps, grp => grp.compileCommandFragments || [])];
const defines = [...new Set(util.flatMap(grps, grp => grp.defines || []))];
const sysroot = target.sysroot;
this.targets.push({ name: target.name, type: target.type });
Expand Down
13 changes: 13 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,19 @@ export function* flatMap<In, Out>(rng: Iterable<In>, fn: (item: In) => Iterable<
}
}

/**
* Get the first non-empty item from an object that produces arrays of objects.
*/
export function first<In, Out>(array: Iterable<In>, fn: (item: In) => Out[]): Out[] {
for (const item of array) {
const result = fn(item);
if (result?.length > 0) {
return result;
}
}
return [];
}

export function makeDebuggerEnvironmentVars(env?: Environment): DebuggerEnvironmentVariable[] {
if (!env) {
return [];
Expand Down