close file also works on non file editors (fixes #3439)

This commit is contained in:
Benjamin Pasero
2016-03-03 07:32:52 +01:00
parent 7e89b382ef
commit 6f9385fb3d
@@ -2032,10 +2032,11 @@ export class CloseFileAction extends Action {
}
public run(): TPromise<any> {
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."));