fix(examples): code-only examples honor languageMode in the filename
A micropython example that ships only 'code:' landed its Python in sketch.ino (the mode switch was right, the name was not - seen on the SensAirShuttle ws2812 example). main.py / main.c / sketch.ino by mode.
This commit is contained in:
parent
3d2a3534b4
commit
7dc88b45e0
|
|
@ -327,7 +327,16 @@ export async function loadExample(
|
|||
if (boardOwnedFiles.length > 0) {
|
||||
editorStore.loadFiles(boardOwnedFiles);
|
||||
} else {
|
||||
const filename = isPiBoardKind(liveBoard.boardKind) ? 'main.cpp' : 'sketch.ino';
|
||||
// The name must match the mode the board was just switched into:
|
||||
// MicroPython pastes main.py, ESP-IDF builds main.c — a bare `code:`
|
||||
// example otherwise lands its Python in a file called sketch.ino.
|
||||
const filename = isPiBoardKind(liveBoard.boardKind)
|
||||
? 'main.cpp'
|
||||
: example.languageMode === 'micropython'
|
||||
? 'main.py'
|
||||
: example.languageMode === 'espidf'
|
||||
? 'main.c'
|
||||
: 'sketch.ino';
|
||||
editorStore.loadFiles([{ name: filename, content: example.code }]);
|
||||
}
|
||||
} else if (chipGroupIds.length > 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue