From 86f2dde6f379892a55db3519a8fc7493d85b4585 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 8 Feb 2020 21:36:32 +0200 Subject: [PATCH] Do not overwrite a custom items in VSCode's "extensions.json" // Resolve #3374 --- HISTORY.rst | 2 ++ .../tpls/vscode/.vscode/extensions.json.tpl | 27 ++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index b33e3c50..8712a677 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -34,6 +34,7 @@ PlatformIO Core 4.0 * Updated Unity tool to 2.5.0 * Made package ManifestSchema compatible with marshmallow >= 3 (`issue #3296 `_) * Warn about broken library manifest when scanning dependencies (`issue #3268 `_) +* Do not overwrite a custom items in VSCode's "extensions.json" (`issue #3374 `_) * Fixed an issue when ``env.BoardConfig()`` does not work for custom boards in extra scripts of libraries (`issue #3264 `_) * Fixed an issue with "start-group/end-group" linker flags on Native development platform (`issue #3282 `_) * Fixed default PIO Unified Debugger configuration for `J-Link probe `__ @@ -45,6 +46,7 @@ PlatformIO Core 4.0 * Fixed an issue with improperly handled compiler flags with space symbols in VSCode template (`issue #3364 `_) * Fixed an issue when no error is raised if referred parameter (interpolation) is missing in a project configuration file (`issue #3279 `_) + 4.1.0 (2019-11-07) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/ide/tpls/vscode/.vscode/extensions.json.tpl b/platformio/ide/tpls/vscode/.vscode/extensions.json.tpl index 8281e64c..62dfebad 100644 --- a/platformio/ide/tpls/vscode/.vscode/extensions.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/extensions.json.tpl @@ -1,7 +1,22 @@ +% import json +% import os +% import re +% +% recommendations = set(["platformio.platformio-ide"]) +% previous_json = os.path.join(project_dir, ".vscode", "extensions.json") +% if os.path.isfile(previous_json): +% with open(previous_json) as fp: +% contents = re.sub(r"^\s*//.*$", "", fp.read(), flags=re.M).strip() +% if contents: +% recommendations |= set(json.loads(contents).get("recommendations", [])) +% end +% end { - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ] -} \ No newline at end of file + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ +% for i, item in enumerate(sorted(recommendations)): + "{{ item }}"{{ ("," if (i + 1) < len(recommendations) else "") }} +% end + ] +}