Skip to content

Commit 55aece5

Browse files
committed
Fix project file update logic by using a deep clone of used items
1 parent cf3fc5b commit 55aece5

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/views/manage-components-packs/components-packs-webview-main.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { BuildContext, Project, TargetSetData } from './components-data';
3131
import { ComponentsPacksActions, CurrentProject, normalizeForCompare } from './components-packs-actions';
3232
import { ComponentRowDataType, ComponentScope } from './data/component-tools';
3333
import { componentTreeWalker } from './data/component-tree-walker';
34-
import { uniqWith } from 'lodash';
34+
import { uniqWith, cloneDeep } from 'lodash';
3535
import { parsePackId } from './data/pack-parse';
3636
import { lineOf, readTextFile } from '../../utils/fs-utils';
3737
import { stripTwoExtensions } from '../../utils/string-utils';
@@ -420,11 +420,12 @@ export class ComponentsPacksWebviewMain {
420420
const activeContext = this.getActiveContext();
421421
const state = await this.csolutionService.apply({ context: activeContext });
422422
this.usedItems = await this.csolutionService.getUsedItems({ context: activeContext });
423+
const usedItemsForProjectFileUpdate = cloneDeep(this.usedItems);
423424
const projectFileName = this.currentProject?.project.projectId ?? '';
424425
const requestAll = this.scope === ComponentScope.All;
425426
this.componentTree = this.manageComponentsActions.mapComponentsFromService(await this.csolutionService.getComponentsTree({ context: activeContext, all: requestAll }));
426427
this.validations = await this.csolutionService.validateComponents({ context: activeContext });
427-
await this.projectFileUpdater.updateUsedItems(activeContext, projectFileName, this.usedItems);
428+
await this.projectFileUpdater.updateUsedItems(activeContext, projectFileName, usedItemsForProjectFileUpdate);
428429

429430
await Promise.all([
430431
this.webviewManager.sendMessage({ type: 'SET_ERROR_MESSAGES', messages: [] }),
@@ -433,7 +434,7 @@ export class ComponentsPacksWebviewMain {
433434
if (state.success === false) {
434435
this.webviewManager.sendMessage({ type: 'SET_SOLUTION_STATE', stateMessage: state.message ?? 'Unspecified error when writing solution information' });
435436
}
436-
await this.sendDirtyState({ skipApply: true, usedItems: this.usedItems });
437+
await this.sendDirtyState({ skipApply: true, usedItems: usedItemsForProjectFileUpdate });
437438
}
438439

439440
private async handleOpenFile(message: Messages.OutgoingMessage): Promise<void> {

0 commit comments

Comments
 (0)