Skip to content

Commit 1d2347f

Browse files
authored
Merge pull request #290 from paulober/develop
Patch v4.2.2
2 parents eb4ddf0 + b8666c5 commit 1d2347f

File tree

7 files changed

+338
-236
lines changed

7 files changed

+338
-236
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ All notable changes to the "MicroPico" extension will be documented in this file
1010

1111
---
1212

13+
## [4.2.2] - 2025-03-27
14+
15+
### Changed
16+
17+
- Updated dependencies
18+
- Updated included stubs to 1.24.* (Fix #289)
19+
- Fixed #288, Extension freezes when run command is triggered while a command is still running
20+
1321
## [4.2.0] - 2025-01-17
1422

1523
### Changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
**MicroPico** is a Visual Studio Code extension designed to simplify and accelerate the development of MicroPython projects for the Raspberry Pi Pico and Pico W boards. This tool streamlines the coding process, providing code highlighting, auto-completion, code snippets, and project management features, all tailored for the seamless development experience with MicroPython on Raspberry Pi Pico and Pico W microcontrollers.
66

7-
> __Included auto-completion based on Raspberry Pi Pico W MicroPython firmware: [RPI_PICO_W-20240602-v1.23.0.uf2](https://micropython.org/resources/firmware/RPI_PICO_W-20240602-v1.23.0.uf2) from the [micropython-stubs project](https://github.com/Josverl/micropython-stubs)__
7+
> __Included auto-completion based on Raspberry Pi Pico W MicroPython firmware: [RPI_PICO_W-20241129-v1.24.1.uf2](https://micropython.org/resources/firmware/RPI_PICO_W-20241129-v1.24.1.uf2) from the [micropython-stubs project](https://github.com/Josverl/micropython-stubs)__
88
99
Works with:
1010
| Platform | x86 | arm64 | armhf |

package-lock.json

Lines changed: 243 additions & 217 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "pico-w-go",
33
"displayName": "MicroPico",
44
"description": "Auto-completion, remote workspace and a REPL console integration for the Raspberry Pi Pico boards running MicroPython firmware.",
5-
"version": "4.2.1",
5+
"version": "4.2.2",
66
"publisher": "paulober",
77
"license": "MPL-2.0",
88
"homepage": "https://github.com/paulober/MicroPico/blob/main/README.md",
@@ -634,7 +634,7 @@
634634
"scripts": {
635635
"vscode:uninstall": "node ./dist/vscodeUninstall.mjs",
636636
"vscode:prepublish": "npm run package",
637-
"postinstall": "patch-package && python3 -m pip install -U micropython-rp2-rpi_pico_w-stubs==1.23.* --target ./mpy_stubs --no-user",
637+
"postinstall": "patch-package && python3 -m pip install -U micropython-rp2-rpi_pico_w-stubs==1.24.* --target ./mpy_stubs --no-user",
638638
"cp-prebuilds": "cp -r node_modules/@serialport/bindings-cpp/prebuilds ./prebuilds",
639639
"compile-uninstaller": "rollup -c uninstall.rollup.config.mjs --environment BUILD:production",
640640
"compile": "rollup -c && npm run compile-uninstaller",
@@ -648,39 +648,39 @@
648648
"test": "node ./out/test/runTest.js"
649649
},
650650
"devDependencies": {
651-
"@eslint/js": "^9.18.0",
652-
"@rollup/plugin-commonjs": "^28.0.2",
651+
"@eslint/js": "^9.23.0",
652+
"@rollup/plugin-commonjs": "^28.0.3",
653653
"@rollup/plugin-json": "^6.1.0",
654-
"@rollup/plugin-node-resolve": "^16.0.0",
654+
"@rollup/plugin-node-resolve": "^16.0.1",
655655
"@rollup/plugin-terser": "^0.4.4",
656656
"@rollup/plugin-typescript": "^12.1.2",
657657
"@serialport/bindings-cpp": "^13.0.1",
658658
"@types/eslint": "^9.6.1",
659659
"@types/fs-extra": "^11.0.4",
660-
"@types/lodash": "^4.17.14",
660+
"@types/lodash": "^4.17.16",
661661
"@types/node": "^20.14",
662662
"@types/uuid": "^10.0.0",
663663
"@types/vscode": "^1.92.0",
664664
"@types/which": "^3.0.4",
665665
"@vscode/test-electron": "^2.4.1",
666-
"eslint": "^9.18.0",
667-
"eslint-config-prettier": "^10.0.1",
666+
"eslint": "^9.23.0",
667+
"eslint-config-prettier": "^10.1.1",
668668
"patch-package": "^8.0.0",
669-
"rollup": "^4.30.1",
669+
"rollup": "^4.37.0",
670670
"rollup-plugin-copy": "^3.5.0",
671671
"tslib": "^2.8.1",
672-
"typescript": "^5.7.3",
673-
"typescript-eslint": "^8.20.0"
672+
"typescript": "^5.8.2",
673+
"typescript-eslint": "^8.28.0"
674674
},
675675
"dependencies": {
676676
"@paulober/pico-mpy-com": "^1.0.22",
677677
"@vscode/python-extension": "^1.0.5",
678-
"axios": "^1.7.7",
678+
"axios": "^1.8.4",
679679
"fs-extra": "^11.3.0",
680680
"lodash": "^4.17.21",
681681
"rimraf": "^6.0.1",
682-
"undici": "^6.21.0",
683-
"uuid": "^11.0.5",
682+
"undici": "^6.21.1",
683+
"uuid": "^11.1.0",
684684
"which": "^5.0.0"
685685
},
686686
"packageManager": "[email protected]+sha512.d08425c8062f56d43bb8e84315864218af2492eb769e1f1ca40740f44e85bd148969382d651660363942e5909cb7ffcbef7ca0ae963ddc2c57a51243b4da8f56"

src/activator.mts

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default class Activator {
6565
private commandExecuting = false;
6666

6767
private disableExtWarning = false;
68+
private statusbarMsgDisposable?: vscode.Disposable;
6869

6970
constructor() {
7071
this.logger = new Logger("Activator");
@@ -542,13 +543,16 @@ export default class Activator {
542543
}
543544
}
544545

546+
if (await this.checkForRunningOperation()) {
547+
return;
548+
}
549+
545550
const forceDisableSoftReset =
546551
this.settings?.getBoolean(SettingsKey.noSoftResetOnRun) ?? false;
547552

548553
if (!noSoftReset && !forceDisableSoftReset) {
549554
await PicoMpyCom.getInstance().softReset();
550555
}
551-
await focusTerminal(this.terminalOptions);
552556
// TODO: maybe freeze terminal until this operation runs to prevent user input
553557
const data = await PicoMpyCom.getInstance().runFile(
554558
file,
@@ -557,6 +561,7 @@ export default class Activator {
557561
return;
558562
}
559563

564+
void focusTerminal(this.terminalOptions);
560565
this.commandExecuting = true;
561566
this.terminal?.cleanAndStore();
562567
this.ui?.userOperationStarted();
@@ -610,6 +615,11 @@ export default class Activator {
610615

611616
return;
612617
}
618+
619+
if (await this.checkForRunningOperation()) {
620+
return;
621+
}
622+
613623
const forceDisableSoftReset =
614624
this.settings?.getBoolean(SettingsKey.noSoftResetOnRun) ?? false;
615625

@@ -2172,4 +2182,47 @@ export default class Activator {
21722182
);
21732183
}
21742184
}
2185+
2186+
/**
2187+
* Checks if there is a running operation and asks the user if it should be canceled.
2188+
*
2189+
* @returns `true` if the user does not want to cancel the already running
2190+
* operation, `false` otherwise.
2191+
*/
2192+
private async checkForRunningOperation(): Promise<boolean> {
2193+
if (this.commandExecuting) {
2194+
// ask user if it want to cancel running operation or cancel the new one
2195+
const choice = await vscode.window.showWarningMessage(
2196+
"An operation is already running. Do you want to cancel it?",
2197+
{
2198+
modal: true,
2199+
},
2200+
"Yes",
2201+
"No"
2202+
);
2203+
2204+
if (choice === "Yes") {
2205+
if (this.commandExecuting) {
2206+
PicoMpyCom.getInstance().interruptExecution();
2207+
2208+
// wait for 500ms for operation to stop and clean up local state
2209+
await new Promise(resolve => setTimeout(resolve, 500));
2210+
}
2211+
} else {
2212+
if (this.statusbarMsgDisposable) {
2213+
this.statusbarMsgDisposable.dispose();
2214+
}
2215+
2216+
// void vscode.window.showWarningMessage("Operation canceled.");
2217+
this.statusbarMsgDisposable = vscode.window.setStatusBarMessage(
2218+
"Operation canceled.",
2219+
5000
2220+
);
2221+
2222+
return true;
2223+
}
2224+
}
2225+
2226+
return false;
2227+
}
21752228
}

src/logger.mts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { window } from "vscode";
2-
import type { LogOutputChannel } from "vscode";
1+
import { env, window } from "vscode";
2+
import { type LogOutputChannel, LogLevel as VSCodeLogLevel } from "vscode";
33

44
type LogLevel = "info" | "warn" | "error" | "debug";
55

@@ -21,6 +21,19 @@ interface Stringable {
2121
toString(): string;
2222
}
2323

24+
function customLogLevelToVscode(logLevel: LogLevel): VSCodeLogLevel {
25+
switch (logLevel) {
26+
case "info":
27+
return VSCodeLogLevel.Info;
28+
case "warn":
29+
return VSCodeLogLevel.Warning;
30+
case "error":
31+
return VSCodeLogLevel.Error;
32+
case "debug":
33+
return VSCodeLogLevel.Debug;
34+
}
35+
}
36+
2437
export default class Logger {
2538
private className: string;
2639
private static outputChannel?: LogOutputChannel;
@@ -33,6 +46,7 @@ export default class Logger {
3346
/*Logger.outputChannel = window.createOutputChannel("Pico-W-Go", {
3447
log: true,
3548
});*/
49+
//env.logLevel = customLogLevelToVscode(logLevel);
3650
Logger.outputChannel = window.createOutputChannel("MicroPico", {
3751
log: true,
3852
});

src/ui.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default class UI {
5050
item.tooltip
5151
);
5252
}
53+
this.statusbarItemPriority = Object.keys(this.items).length;
5354

5455
this.setState(false);
5556

@@ -128,7 +129,7 @@ export default class UI {
128129
return;
129130
}
130131

131-
private statusbarItemPriority = 11;
132+
private statusbarItemPriority = 14;
132133

133134
private createStatusBarItem(
134135
key: string,

0 commit comments

Comments
 (0)