diff --git a/CHANGELOG.md b/CHANGELOG.md index d6c8b228..3a11ba55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ ## [Unreleased] +### Fixed +- Show error message when go to syntax error fails to activate file ([support#924]). + +[support#924]: https://github.com/pybricks/support/issues/924 + ## [2.1.0] - 2023-01-06 ### Changed diff --git a/src/editor/sagas.ts b/src/editor/sagas.ts index 0fc37c71..b31e9537 100644 --- a/src/editor/sagas.ts +++ b/src/editor/sagas.ts @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2022 The Pybricks Authors +// Copyright (c) 2022-2023 The Pybricks Authors import type { DatabaseChangeType, IDatabaseChange } from 'dexie-observable/api'; import * as monaco from 'monaco-editor'; @@ -16,6 +16,7 @@ import { take, takeEvery, } from 'typed-redux-saga/macro'; +import { alertsShowAlert } from '../alerts/actions'; import { FileStorageDb, UUID } from '../fileStorage'; import { fileStorageDidFailToLoadTextFile, @@ -257,6 +258,27 @@ function* handleEditorGoto( }); if (didFailToActivate) { + if ( + didFailToActivate.error instanceof EditorError && + didFailToActivate.error.name === 'FileInUse' + ) { + const db = yield* getContext('fileStorage'); + + const metadata = yield* call(() => db.metadata.get(action.uuid)); + + yield* put( + alertsShowAlert('explorer', 'fileInUse', { + fileName: metadata?.path ?? '', + }), + ); + } else { + yield* put( + alertsShowAlert('alerts', 'unexpectedError', { + error: didFailToActivate.error, + }), + ); + } + return; }