Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch v4.2.2 #290

Merged
merged 5 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ All notable changes to the "MicroPico" extension will be documented in this file

---

## [4.2.2] - 2025-03-27

### Changed

- Updated dependencies
- Updated included stubs to 1.24.* (Fix #289)
- Fixed #288, Extension freezes when run command is triggered while a command is still running

## [4.2.0] - 2025-01-17

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**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.

> __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)__
> __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)__

Works with:
| Platform | x86 | arm64 | armhf |
Expand Down
460 changes: 243 additions & 217 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pico-w-go",
"displayName": "MicroPico",
"description": "Auto-completion, remote workspace and a REPL console integration for the Raspberry Pi Pico boards running MicroPython firmware.",
"version": "4.2.1",
"version": "4.2.2",
"publisher": "paulober",
"license": "MPL-2.0",
"homepage": "https://github.com/paulober/MicroPico/blob/main/README.md",
Expand Down Expand Up @@ -634,7 +634,7 @@
"scripts": {
"vscode:uninstall": "node ./dist/vscodeUninstall.mjs",
"vscode:prepublish": "npm run package",
"postinstall": "patch-package && python3 -m pip install -U micropython-rp2-rpi_pico_w-stubs==1.23.* --target ./mpy_stubs --no-user",
"postinstall": "patch-package && python3 -m pip install -U micropython-rp2-rpi_pico_w-stubs==1.24.* --target ./mpy_stubs --no-user",
"cp-prebuilds": "cp -r node_modules/@serialport/bindings-cpp/prebuilds ./prebuilds",
"compile-uninstaller": "rollup -c uninstall.rollup.config.mjs --environment BUILD:production",
"compile": "rollup -c && npm run compile-uninstaller",
Expand All @@ -648,39 +648,39 @@
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@eslint/js": "^9.18.0",
"@rollup/plugin-commonjs": "^28.0.2",
"@eslint/js": "^9.23.0",
"@rollup/plugin-commonjs": "^28.0.3",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.2",
"@serialport/bindings-cpp": "^13.0.1",
"@types/eslint": "^9.6.1",
"@types/fs-extra": "^11.0.4",
"@types/lodash": "^4.17.14",
"@types/lodash": "^4.17.16",
"@types/node": "^20.14",
"@types/uuid": "^10.0.0",
"@types/vscode": "^1.92.0",
"@types/which": "^3.0.4",
"@vscode/test-electron": "^2.4.1",
"eslint": "^9.18.0",
"eslint-config-prettier": "^10.0.1",
"eslint": "^9.23.0",
"eslint-config-prettier": "^10.1.1",
"patch-package": "^8.0.0",
"rollup": "^4.30.1",
"rollup": "^4.37.0",
"rollup-plugin-copy": "^3.5.0",
"tslib": "^2.8.1",
"typescript": "^5.7.3",
"typescript-eslint": "^8.20.0"
"typescript": "^5.8.2",
"typescript-eslint": "^8.28.0"
},
"dependencies": {
"@paulober/pico-mpy-com": "^1.0.22",
"@vscode/python-extension": "^1.0.5",
"axios": "^1.7.7",
"axios": "^1.8.4",
"fs-extra": "^11.3.0",
"lodash": "^4.17.21",
"rimraf": "^6.0.1",
"undici": "^6.21.0",
"uuid": "^11.0.5",
"undici": "^6.21.1",
"uuid": "^11.1.0",
"which": "^5.0.0"
},
"packageManager": "[email protected]+sha512.d08425c8062f56d43bb8e84315864218af2492eb769e1f1ca40740f44e85bd148969382d651660363942e5909cb7ffcbef7ca0ae963ddc2c57a51243b4da8f56"
Expand Down
55 changes: 54 additions & 1 deletion src/activator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default class Activator {
private commandExecuting = false;

private disableExtWarning = false;
private statusbarMsgDisposable?: vscode.Disposable;

constructor() {
this.logger = new Logger("Activator");
Expand Down Expand Up @@ -542,13 +543,16 @@ export default class Activator {
}
}

if (await this.checkForRunningOperation()) {
return;
}

const forceDisableSoftReset =
this.settings?.getBoolean(SettingsKey.noSoftResetOnRun) ?? false;

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

void focusTerminal(this.terminalOptions);
this.commandExecuting = true;
this.terminal?.cleanAndStore();
this.ui?.userOperationStarted();
Expand Down Expand Up @@ -610,6 +615,11 @@ export default class Activator {

return;
}

if (await this.checkForRunningOperation()) {
return;
}

const forceDisableSoftReset =
this.settings?.getBoolean(SettingsKey.noSoftResetOnRun) ?? false;

Expand Down Expand Up @@ -2172,4 +2182,47 @@ export default class Activator {
);
}
}

/**
* Checks if there is a running operation and asks the user if it should be canceled.
*
* @returns `true` if the user does not want to cancel the already running
* operation, `false` otherwise.
*/
private async checkForRunningOperation(): Promise<boolean> {
if (this.commandExecuting) {
// ask user if it want to cancel running operation or cancel the new one
const choice = await vscode.window.showWarningMessage(
"An operation is already running. Do you want to cancel it?",
{
modal: true,
},
"Yes",
"No"
);

if (choice === "Yes") {
if (this.commandExecuting) {
PicoMpyCom.getInstance().interruptExecution();

// wait for 500ms for operation to stop and clean up local state
await new Promise(resolve => setTimeout(resolve, 500));
}
} else {
if (this.statusbarMsgDisposable) {
this.statusbarMsgDisposable.dispose();
}

// void vscode.window.showWarningMessage("Operation canceled.");
this.statusbarMsgDisposable = vscode.window.setStatusBarMessage(
"Operation canceled.",
5000
);

return true;
}
}

return false;
}
}
18 changes: 16 additions & 2 deletions src/logger.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { window } from "vscode";
import type { LogOutputChannel } from "vscode";
import { env, window } from "vscode";
import { type LogOutputChannel, LogLevel as VSCodeLogLevel } from "vscode";

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

Expand All @@ -21,6 +21,19 @@ interface Stringable {
toString(): string;
}

function customLogLevelToVscode(logLevel: LogLevel): VSCodeLogLevel {
switch (logLevel) {
case "info":
return VSCodeLogLevel.Info;
case "warn":
return VSCodeLogLevel.Warning;
case "error":
return VSCodeLogLevel.Error;
case "debug":
return VSCodeLogLevel.Debug;
}
}

export default class Logger {
private className: string;
private static outputChannel?: LogOutputChannel;
Expand All @@ -33,6 +46,7 @@ export default class Logger {
/*Logger.outputChannel = window.createOutputChannel("Pico-W-Go", {
log: true,
});*/
//env.logLevel = customLogLevelToVscode(logLevel);
Logger.outputChannel = window.createOutputChannel("MicroPico", {
log: true,
});
Expand Down
3 changes: 2 additions & 1 deletion src/ui.mts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class UI {
item.tooltip
);
}
this.statusbarItemPriority = Object.keys(this.items).length;

this.setState(false);

Expand Down Expand Up @@ -128,7 +129,7 @@ export default class UI {
return;
}

private statusbarItemPriority = 11;
private statusbarItemPriority = 14;

private createStatusBarItem(
key: string,
Expand Down
Loading