diff --git a/arduino-ide-extension/src/browser/theia/core/application-shell.ts b/arduino-ide-extension/src/browser/theia/core/application-shell.ts index dd68beeff..eb419dcec 100644 --- a/arduino-ide-extension/src/browser/theia/core/application-shell.ts +++ b/arduino-ide-extension/src/browser/theia/core/application-shell.ts @@ -17,6 +17,7 @@ import { Sketch } from '../../../common/protocol'; import { SaveAsSketch } from '../../contributions/save-as-sketch'; import { SketchesServiceClientImpl } from '../../../common/protocol/sketches-service-client-impl'; import { nls } from '@theia/core/lib/common'; +import URI from '@theia/core/lib/common/uri'; @injectable() export class ApplicationShell extends TheiaApplicationShell { @@ -41,6 +42,9 @@ export class ApplicationShell extends TheiaApplicationShell { // Make the editor un-closeable asynchronously. this.sketchesServiceClient.currentSketch().then((sketch) => { if (sketch) { + if (!this.isSketchFile(widget.editor.uri, sketch.uri)) { + return; + } if (Sketch.isInSketch(widget.editor.uri, sketch)) { widget.title.closable = false; } @@ -49,6 +53,14 @@ export class ApplicationShell extends TheiaApplicationShell { } } + private isSketchFile(uri: URI, sketchUriString: string): boolean { + const sketchUri = new URI(sketchUriString); + if (uri.parent.isEqual(sketchUri)) { + return true; + } + return false; + } + async addWidget( widget: Widget, options: Readonly = {}