From bc9d9ac2db09421dba84c323683dc4b5baecdf24 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 9 Aug 2022 15:47:04 +0300 Subject: [PATCH] Keep custom "unwantedRecommendations" when generating projects for VSCode // Resolve #4383 --- HISTORY.rst | 3 ++- .../tpls/vscode/.vscode/extensions.json.tpl | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index d51051d0..0acfa211 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,7 +20,8 @@ PlatformIO Core 6 * Improved device port finder when using dual channel UART converter (`issue #4367 `_) * Improved project dependency resolving when using the `pio project init --ide `__ command * Upgraded build engine to the SCons 4.4.0 (`release notes `__) -* Do not resolve project dependencies on for the ``cleanall`` target (`issue #4344 `_) +* Keep custom "unwantedRecommendations" when generating projects for VSCode (`issue #4383 `_) +* Do not resolve project dependencies for the ``cleanall`` target (`issue #4344 `_) * Warn about calling "env.BuildSources" in a POST-type script (`issue #4385 `_) * Fixed an issue when escaping macros/defines for IDE integration (`issue #4360 `_) diff --git a/platformio/project/integration/tpls/vscode/.vscode/extensions.json.tpl b/platformio/project/integration/tpls/vscode/.vscode/extensions.json.tpl index 26412ae7..8d8e8a02 100644 --- a/platformio/project/integration/tpls/vscode/.vscode/extensions.json.tpl +++ b/platformio/project/integration/tpls/vscode/.vscode/extensions.json.tpl @@ -3,13 +3,20 @@ % import re % % recommendations = set(["platformio.platformio-ide"]) +% unwantedRecommendations = set(["ms-vscode.cpptools-extension-pack"]) % previous_json = os.path.join(project_dir, ".vscode", "extensions.json") % if os.path.isfile(previous_json): % fp = open(previous_json) % contents = re.sub(r"^\s*//.*$", "", fp.read(), flags=re.M).strip() % fp.close() % if contents: -% recommendations |= set(json.loads(contents).get("recommendations", [])) +% try: +% data = json.loads(contents) +% recommendations |= set(data.get("recommendations", [])) +% unwantedRecommendations |= set(data.get("unwantedRecommendations", [])) +% except ValueError: +% pass +% end % end % end { @@ -21,6 +28,8 @@ % end ], "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" +% for i, item in enumerate(sorted(unwantedRecommendations)): + "{{ item }}"{{ ("," if (i + 1) < len(unwantedRecommendations) else "") }} +% end ] }