mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-25 20:26:38 +00:00
fixed closeable state.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
f375202c5d
commit
9ee5fc097c
@ -20,32 +20,24 @@ export class ApplicationShell extends TheiaApplicationShell {
|
|||||||
@inject(SketchesServiceClientImpl)
|
@inject(SketchesServiceClientImpl)
|
||||||
protected readonly sketchesServiceClient: SketchesServiceClientImpl;
|
protected readonly sketchesServiceClient: SketchesServiceClientImpl;
|
||||||
|
|
||||||
protected sketch?: Sketch;
|
|
||||||
|
|
||||||
async addWidget(widget: Widget, options: Readonly<TheiaApplicationShell.WidgetOptions> = {}): Promise<void> {
|
|
||||||
// Get the current sketch before adding a widget. This wil trigger an update.
|
|
||||||
this.sketch = await this.sketchesServiceClient.currentSketch();
|
|
||||||
super.addWidget(widget, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
async setLayoutData(layoutData: TheiaApplicationShell.LayoutData): Promise<void> {
|
|
||||||
// I could not find other ways to get sketch in async fashion for sync `track`.
|
|
||||||
this.sketch = await this.sketchesServiceClient.currentSketch();
|
|
||||||
super.setLayoutData(layoutData);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected track(widget: Widget): void {
|
protected track(widget: Widget): void {
|
||||||
if (!this.editorMode.proMode && this.sketch && widget instanceof EditorWidget) {
|
|
||||||
if (Sketch.isInSketch(widget.editor.uri, this.sketch)) {
|
|
||||||
widget.title.closable = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.track(widget);
|
super.track(widget);
|
||||||
|
if (!this.editorMode.proMode && widget instanceof EditorWidget) {
|
||||||
|
// Make the editor un-closeable asynchronously.
|
||||||
|
this.sketchesServiceClient.currentSketch().then(sketch => {
|
||||||
|
if (sketch) {
|
||||||
|
if (Sketch.isInSketch(widget.editor.uri, sketch)) {
|
||||||
|
widget.title.closable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveAll(): Promise<void> {
|
async saveAll(): Promise<void> {
|
||||||
await super.saveAll();
|
await super.saveAll();
|
||||||
await this.commandService.executeCommand(SaveAsSketch.Commands.SAVE_AS_SKETCH.id, { execOnlyIfTemp: true, openAfterMove: true });
|
const options = { execOnlyIfTemp: true, openAfterMove: true };
|
||||||
|
await this.commandService.executeCommand(SaveAsSketch.Commands.SAVE_AS_SKETCH.id, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ export namespace Sketch {
|
|||||||
}
|
}
|
||||||
export function isInSketch(uri: string | URI, sketch: Sketch): boolean {
|
export function isInSketch(uri: string | URI, sketch: Sketch): boolean {
|
||||||
const { mainFileUri, otherSketchFileUris, additionalFileUris } = sketch;
|
const { mainFileUri, otherSketchFileUris, additionalFileUris } = sketch;
|
||||||
return [mainFileUri, ...otherSketchFileUris, additionalFileUris].indexOf(uri.toString()) !== -1;
|
return [mainFileUri, ...otherSketchFileUris, ...additionalFileUris].indexOf(uri.toString()) !== -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user