Allow to close files in certain folders (#946)

* Allow to close files in certain folders

* Only direct children are sketch files
This commit is contained in:
Mark Sujew 2022-04-19 12:00:15 +02:00 committed by GitHub
parent 58e992af13
commit c07232698c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<TheiaApplicationShell.WidgetOptions> = {}