From c59e5e4aead4d0a0417d7f198385d5abff0ad22e Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Wed, 6 Apr 2022 12:04:02 +0200 Subject: [PATCH 1/2] Allow to close files in certain folders --- .../src/browser/theia/core/application-shell.ts | 8 ++++++++ 1 file changed, 8 insertions(+) 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..ea327dd05 100644 --- a/arduino-ide-extension/src/browser/theia/core/application-shell.ts +++ b/arduino-ide-extension/src/browser/theia/core/application-shell.ts @@ -41,6 +41,14 @@ export class ApplicationShell extends TheiaApplicationShell { // Make the editor un-closeable asynchronously. this.sketchesServiceClient.currentSketch().then((sketch) => { if (sketch) { + const ignoreFolders = ['.vscode', '.theia', 'src']; + let editorPath = widget.editor.uri; + while (editorPath.toString().length > sketch.uri.length) { + if (ignoreFolders.includes(editorPath.path.base)) { + return; + } + editorPath = editorPath.parent; + } if (Sketch.isInSketch(widget.editor.uri, sketch)) { widget.title.closable = false; } From 93e73d7f26fb405ac3ca562bae83e9fd9c02cf6a Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Tue, 12 Apr 2022 15:15:00 +0200 Subject: [PATCH 2/2] Only direct children are sketch files --- .../src/browser/theia/core/application-shell.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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 ea327dd05..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,13 +42,8 @@ export class ApplicationShell extends TheiaApplicationShell { // Make the editor un-closeable asynchronously. this.sketchesServiceClient.currentSketch().then((sketch) => { if (sketch) { - const ignoreFolders = ['.vscode', '.theia', 'src']; - let editorPath = widget.editor.uri; - while (editorPath.toString().length > sketch.uri.length) { - if (ignoreFolders.includes(editorPath.path.base)) { + if (!this.isSketchFile(widget.editor.uri, sketch.uri)) { return; - } - editorPath = editorPath.parent; } if (Sketch.isInSketch(widget.editor.uri, sketch)) { widget.title.closable = false; @@ -57,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 = {}