From 33b45ef6bce82ae14ee8b97fd189ae2c625ea4e9 Mon Sep 17 00:00:00 2001 From: Grace Date: Thu, 30 Apr 2026 15:13:46 +0100 Subject: [PATCH] Don't check board version if device is not connected Since upgrading the connection library, getBoardVersion throws "Not connected" error if micro:bit is not connected. In this case, we only want to check the board version to warn users of v2-only APIs when the micro:bit is connected. --- src/editor/codemirror/language-server/diagnostics.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/editor/codemirror/language-server/diagnostics.ts b/src/editor/codemirror/language-server/diagnostics.ts index ae3e96b88..8239a8f3a 100644 --- a/src/editor/codemirror/language-server/diagnostics.ts +++ b/src/editor/codemirror/language-server/diagnostics.ts @@ -8,6 +8,7 @@ import * as LSP from "vscode-languageserver-protocol"; import { Action, Diagnostic } from "../lint/lint"; import { positionToOffset } from "./positions"; import { MicrobitUSBConnection } from "@microbit/microbit-connection/usb"; +import { ConnectionStatus } from "@microbit/microbit-connection"; const reportMicrobitVersionApiUnsupported = "reportMicrobitVersionApiUnsupported"; @@ -32,7 +33,9 @@ export const diagnosticsMapping = ( // and warnOnV2OnlyFeatures setting is on. if ( code === reportMicrobitVersionApiUnsupported && - (!warnOnV2OnlyFeatures || device.getBoardVersion() !== "V1") + (!warnOnV2OnlyFeatures || + device.status !== ConnectionStatus.Connected || + device.getBoardVersion() !== "V1") ) { return undefined; }