Skip to content

Commit 9ca0df0

Browse files
authored
Fix CMAKE_DO_NOT_EDIT_HEADER_PREFIX grammar (#103)
* Fix CMAKE_DO_NOT_EDIT_HEADER_PREFIX grammar * Update pico_project.py * Update cmakeUtil.mts * Update extension.mts
1 parent 00722b4 commit 9ca0df0

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

scripts/pico_project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,9 @@ def GenerateCMake(folder, params):
583583
"# (note this can come from environment, CMake cache etc)\n\n"
584584
)
585585

586-
# if you change the do never edit headline you need to change the check for it in extension.mts
586+
# if you change the do not edit headline you need to change the check for it in extension.mts
587587
cmake_header_us = (
588-
"# == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work ==\n"
588+
"# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==\n"
589589
"if(WIN32)\n"
590590
" set(USERHOME $ENV{USERPROFILE})\n"
591591
"else()\n"

src/extension.mts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import NewProjectCommand from "./commands/newProject.mjs";
1616
import Logger, { LoggerSource } from "./logger.mjs";
1717
import {
1818
CMAKE_DO_NOT_EDIT_HEADER_PREFIX,
19+
CMAKE_DO_NOT_EDIT_HEADER_PREFIX_OLD,
1920
cmakeGetSelectedBoard,
2021
cmakeGetSelectedToolchainAndSDKVersions,
2122
configureCmakeNinja,
@@ -209,9 +210,14 @@ export async function activate(context: ExtensionContext): Promise<void> {
209210
// check if it has .vscode folder and cmake donotedit header in CMakelists.txt
210211
if (
211212
!existsSync(join(workspaceFolder.uri.fsPath, ".vscode")) ||
212-
!readFileSync(cmakeListsFilePath)
213-
.toString("utf-8")
214-
.includes(CMAKE_DO_NOT_EDIT_HEADER_PREFIX)
213+
!(
214+
readFileSync(cmakeListsFilePath)
215+
.toString("utf-8")
216+
.includes(CMAKE_DO_NOT_EDIT_HEADER_PREFIX) ||
217+
readFileSync(cmakeListsFilePath)
218+
.toString("utf-8")
219+
.includes(CMAKE_DO_NOT_EDIT_HEADER_PREFIX_OLD)
220+
)
215221
) {
216222
Logger.warn(
217223
LoggerSource.extension,

src/utils/cmakeUtil.mts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import { buildCMakeIncPath } from "./download.mjs";
1515

1616
export const CMAKE_DO_NOT_EDIT_HEADER_PREFIX =
1717
// eslint-disable-next-line max-len
18+
"== DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==";
19+
export const CMAKE_DO_NOT_EDIT_HEADER_PREFIX_OLD =
20+
// eslint-disable-next-line max-len
1821
"== DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work ==";
1922

2023
export async function getPythonPath(): Promise<string> {
@@ -322,7 +325,8 @@ export async function cmakeUpdateSDK(
322325
const cmakeFilePath = join(folder.fsPath, "CMakeLists.txt");
323326
// This regex requires multiline (m) and dotall (s) flags to work
324327
const updateSectionRegex = new RegExp(
325-
`^# ${CMAKE_DO_NOT_EDIT_HEADER_PREFIX}.*# =+$`,
328+
`^# (${CMAKE_DO_NOT_EDIT_HEADER_PREFIX}` +
329+
`|${CMAKE_DO_NOT_EDIT_HEADER_PREFIX_OLD}).*# =+$`,
326330
"ms"
327331
);
328332
const picoBoardRegex = /^set\(PICO_BOARD\s+([^)]+)\)$/m;

0 commit comments

Comments
 (0)