From 4dc38176661eb57cdcae17dc39f86d1504363d8d Mon Sep 17 00:00:00 2001 From: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:47:49 -0400 Subject: [PATCH] ensure we take deep copy of presets for presetsPlusIncluded (#3939) --- package.json | 4 +++- src/presetsController.ts | 4 +++- yarn.lock | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76d50e40..5fc63b83 100644 --- a/package.json +++ b/package.json @@ -3702,6 +3702,7 @@ "@types/chai-string": "^1.4.2", "@types/js-yaml": "^4.0.0", "@types/json5": "~0.0.30", + "@types/lodash": "4.14.202", "@types/mocha": "^8.2.2", "@types/node": "~14.14.28", "@types/rimraf": "^3.0.0", @@ -3768,7 +3769,8 @@ "vscode-tas-client": "^0.1.45", "which": "~2.0.2", "xml2js": "^0.4.23", - "uuid": "~8.3.2" + "uuid": "~8.3.2", + "lodash": "^4.17.21" }, "resolutions": { "ansi-regex": "^5.0.1", diff --git a/src/presetsController.ts b/src/presetsController.ts index cd8c06da..27522cdb 100644 --- a/src/presetsController.ts +++ b/src/presetsController.ts @@ -2,6 +2,7 @@ import * as chokidar from 'chokidar'; import * as path from 'path'; import * as vscode from 'vscode'; import * as nls from 'vscode-nls'; +import * as lodash from "lodash"; import { CMakeProject, ConfigureTrigger, ConfigureType } from '@cmt/cmakeProject'; import * as logging from '@cmt/logging'; @@ -187,8 +188,9 @@ export class PresetsController { this.populatePrivatePresetsFields(presetsFile, file); await this.mergeIncludeFiles(presetsFile, presetsFile, file, referencedFiles); + const copyOfPresetsFile = lodash.cloneDeep(presetsFile); // add the include files to the original presets file - setPresetsPlusIncluded(this.folderPath, {...presetsFile}); + setPresetsPlusIncluded(this.folderPath, copyOfPresetsFile); // set the pre-expanded version so we can call expandPresetsFile on it setExpandedPresets(this.folderPath, presetsFile); diff --git a/yarn.lock b/yarn.lock index 7c194f09..b1bdbd9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -446,6 +446,11 @@ resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.30.tgz" integrity sha512-sqm9g7mHlPY/43fcSNrCYfOeX9zkTTK+euO5E6+CVijSMm5tTjkVdwdqRkY3ljjIAf8679vps5jKUoJBCLsMDA== +"@types/lodash@4.14.202": + version "4.14.202" + resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.202.tgz#f09dbd2fb082d507178b2f2a5c7e74bd72ff98f8" + integrity sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ== + "@types/minimatch@*", "@types/minimatch@^3.0.3": version "3.0.5" resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz"