raspberrypi / pico-vscode

The official VS Code extension for Raspberry Pi Pico development. It includes several features to simplify project creation and deployment.
https://marketplace.visualstudio.com/items?itemName=raspberry-pi.raspberry-pi-pico
Mozilla Public License 2.0
132 stars 16 forks source link

Fix CMAKE_DO_NOT_EDIT_HEADER_PREFIX grammar #103

Closed NickGuyver closed 3 weeks ago

will-v-pi commented 1 month ago

This change would break all backwards compatibility as that string is searched for to detect a pico-vscode project, and the header is also specified in pico_platform.py so would need to be changed there too. Could you modify this PR to address those concerns?

NickGuyver commented 1 month ago

This change would break all backwards compatibility as that string is searched for to detect a pico-vscode project, and the header is also specified in pico_platform.py so would need to be changed there too. Could you modify this PR to address those concerns?

PR modified as requested.

NickGuyver commented 3 weeks ago

Actually one more change is needed in extension.mts, else it won't detect older projects as pico projects - this diff would work

diff --git a/src/extension.mts b/src/extension.mts
index 15b2b76..83f276e 100644
--- a/src/extension.mts
+++ b/src/extension.mts
@@ -16,6 +16,7 @@ import NewProjectCommand from "./commands/newProject.mjs";
 import Logger, { LoggerSource } from "./logger.mjs";
 import {
   CMAKE_DO_NOT_EDIT_HEADER_PREFIX,
+  CMAKE_DO_NOT_EDIT_HEADER_PREFIX_OLD,
   cmakeGetSelectedBoard,
   cmakeGetSelectedToolchainAndSDKVersions,
   configureCmakeNinja,
@@ -209,9 +210,14 @@ export async function activate(context: ExtensionContext): Promise<void> {
   // check if it has .vscode folder and cmake donotedit header in CMakelists.txt
   if (
     !existsSync(join(workspaceFolder.uri.fsPath, ".vscode")) ||
-    !readFileSync(cmakeListsFilePath)
-      .toString("utf-8")
-      .includes(CMAKE_DO_NOT_EDIT_HEADER_PREFIX)
+    !(
+      readFileSync(cmakeListsFilePath)
+        .toString("utf-8")
+        .includes(CMAKE_DO_NOT_EDIT_HEADER_PREFIX) ||
+      readFileSync(cmakeListsFilePath)
+        .toString("utf-8")
+        .includes(CMAKE_DO_NOT_EDIT_HEADER_PREFIX_OLD)
+    )
   ) {
     Logger.warn(
       LoggerSource.extension,

With this fix I've tested and am happy to merge this PR

Fix applied, thank you.