Skip to content

Commit

Permalink
Don't merge all the compileCommandFragments for the browse path (#2754)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbrow authored Sep 26, 2022
1 parent 93bae56 commit c7557c8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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

0 comments on commit c7557c8

Please sign in to comment.