Skip to content

Commit 7c5eb6f

Browse files
committed
Automatically remove editors for deleted files
1 parent 9e89964 commit 7c5eb6f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
FrontendApplication,
2121
FrontendApplicationContribution,
2222
LocalStorageService,
23+
SaveableWidget,
2324
StatusBar,
2425
StatusBarAlignment,
2526
} from '@theia/core/lib/browser';
@@ -70,6 +71,7 @@ import { SaveAsSketch } from './contributions/save-as-sketch';
7071
import { SketchbookWidgetContribution } from './widgets/sketchbook/sketchbook-widget-contribution';
7172
import { IDEUpdaterDialog } from './dialogs/ide-updater/ide-updater-dialog';
7273
import { IDEUpdater } from '../common/protocol/ide-updater';
74+
import { FileSystemFrontendContribution } from '@theia/filesystem/lib/browser/filesystem-frontend-contribution';
7375

7476
const INIT_LIBS_AND_PACKAGES = 'initializedLibsAndPackages';
7577
export const SKIP_IDE_VERSION = 'skipIDEVersion';
@@ -159,6 +161,9 @@ export class ArduinoFrontendContribution
159161
@inject(LocalStorageService)
160162
protected readonly localStorageService: LocalStorageService;
161163

164+
@inject(FileSystemFrontendContribution)
165+
protected readonly fileSystemFrontendContribution: FileSystemFrontendContribution;
166+
162167
@inject(IDEUpdater)
163168
protected readonly updater: IDEUpdater;
164169

@@ -337,6 +342,17 @@ export class ArduinoFrontendContribution
337342
});
338343

339344
app.shell.leftPanelHandler.removeBottomMenu('settings-menu');
345+
346+
this.fileSystemFrontendContribution.onDidChangeEditorFile(e => {
347+
if (e.type === FileChangeType.DELETED) {
348+
const editorWidget = e.editor;
349+
if (SaveableWidget.is(editorWidget)) {
350+
editorWidget.closeWithoutSaving();
351+
} else {
352+
editorWidget.close();
353+
}
354+
}
355+
});
340356
}
341357

342358
onStop(): void {

0 commit comments

Comments
 (0)