@@ -36,6 +36,7 @@ import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/ur
36
36
import { IModelService } from 'vs/editor/common/services/modelService' ;
37
37
import { ILogService } from 'vs/platform/log/common/log' ;
38
38
import { ContributedEditorPriority , DEFAULT_EDITOR_ASSOCIATION , IEditorOverrideService } from 'vs/workbench/services/editor/common/editorOverrideService' ;
39
+ import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService' ;
39
40
40
41
type CachedEditorInput = ResourceEditorInput | IFileEditorInput | UntitledTextEditorInput ;
41
42
type OpenInEditorGroup = IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE ;
@@ -75,6 +76,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
75
76
@IUriIdentityService private readonly uriIdentityService : IUriIdentityService ,
76
77
@ILogService private readonly logService : ILogService ,
77
78
@IEditorOverrideService private readonly editorOverrideService : IEditorOverrideService ,
79
+ @IWorkingCopyService private readonly workingCopyService : IWorkingCopyService
78
80
) {
79
81
super ( ) ;
80
82
@@ -318,11 +320,11 @@ export class EditorService extends Disposable implements EditorServiceImpl {
318
320
}
319
321
320
322
// Handle deletes in opened editors depending on:
321
- // - the user has not disabled the setting `closeOnFileDelete`
322
- // - the file change is local
323
- // - the input is a file that is not resolved (we need to dispose because
324
- // we cannot restore otherwise since we do not have the contents)
325
- if ( this . closeOnFileDelete || ! isExternal || ( this . fileEditorInputFactory . isFileEditorInput ( editor ) && ! editor . isResolved ( ) ) ) {
323
+ // - we close any editor when `closeOnFileDelete: true `
324
+ // - we close any editor when the delete occured from within VSCode
325
+ // - we close any editor without resolved working copy assuming that
326
+ // this editor could not be opened after the file is gone
327
+ if ( this . closeOnFileDelete || ! isExternal || ! this . workingCopyService . has ( resource ) ) {
326
328
327
329
// Do NOT close any opened editor that matches the resource path (either equal or being parent) of the
328
330
// resource we move to (movedTo). Otherwise we would close a resource that has been renamed to the same
0 commit comments