-
-
Notifications
You must be signed in to change notification settings - Fork 437
/
Copy pathworkspace-delete-handler.ts
36 lines (34 loc) · 1.33 KB
/
workspace-delete-handler.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { CommandService } from '@theia/core/lib/common/command';
import URI from '@theia/core/lib/common/uri';
import { inject, injectable } from '@theia/core/shared/inversify';
import { WorkspaceDeleteHandler as TheiaWorkspaceDeleteHandler } from '@theia/workspace/lib/browser/workspace-delete-handler';
import { DeleteSketch } from '../../contributions/delete-sketch';
import {
CurrentSketch,
SketchesServiceClientImpl,
} from '../../sketches-service-client-impl';
@injectable()
export class WorkspaceDeleteHandler extends TheiaWorkspaceDeleteHandler {
@inject(CommandService)
private readonly commandService: CommandService;
@inject(SketchesServiceClientImpl)
private readonly sketchesServiceClient: SketchesServiceClientImpl;
override async execute(uris: URI[]): Promise<void> {
const sketch = await this.sketchesServiceClient.currentSketch();
if (!CurrentSketch.isValid(sketch)) {
return;
}
// Deleting the main sketch file means deleting the sketch folder and all its content.
if (uris.some((uri) => uri.toString() === sketch.mainFileUri)) {
return this.commandService.executeCommand(
DeleteSketch.Commands.DELETE_SKETCH.id,
{
toDelete: sketch,
willNavigateAway: true,
}
);
}
// Individual file deletion(s).
return super.execute(uris);
}
}