From 6f9385fb3d22e3eec458791cb4aa3e7e2e2deb4d Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 3 Mar 2016 07:32:52 +0100 Subject: [PATCH] close file also works on non file editors (fixes #3439) --- src/vs/workbench/parts/files/browser/fileActions.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index 6a65867e237..a78d65ad1b7 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -2032,10 +2032,11 @@ export class CloseFileAction extends Action { } public run(): TPromise { + let editor = this.editorService.getActiveEditor(); let input = this.editorService.getActiveEditorInput(); let resource = workbenchEditorCommon.getUntitledOrFileResource(input, true); - // Only works if we have a file or untitled input + // For a file or untitled if (resource) { let model = this.textFileService.getWorkingFilesModel(); let entry = model.findEntry(resource); @@ -2068,6 +2069,11 @@ export class CloseFileAction extends Action { } } + // Any other editor just closes + else if (editor) { + this.editorService.closeEditor(editor).done(null, errors.onUnexpectedError);; + } + // Otherwise tell the user else { this.messageService.show(Severity.Info, nls.localize('noFileOpen', "There is currently no file opened to close."));