From 183d11a642b121c3023d3f1c9f2470263c1452bc Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 7 Sep 2020 12:09:59 +0200 Subject: [PATCH] editors - allow to save virtual documents (fix #101952) --- .../common/editor/textResourceEditorInput.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/common/editor/textResourceEditorInput.ts b/src/vs/workbench/common/editor/textResourceEditorInput.ts index 92bb60db4ad10..40a50a7c44b57 100644 --- a/src/vs/workbench/common/editor/textResourceEditorInput.ts +++ b/src/vs/workbench/common/editor/textResourceEditorInput.ts @@ -137,7 +137,10 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput { } isUntitled(): boolean { - return this.resource.scheme === Schemas.untitled; + // anyFile: is never untitled as it can be saved + // untitled: is untitled by definition + // anyOther: is untitled because it cannot be saved, as such we expect a "Save As" dialog + return !this.fileService.canHandleResource(this.resource); } isReadonly(): boolean { @@ -161,6 +164,14 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput { } save(group: GroupIdentifier, options?: ITextFileSaveOptions): Promise { + + // If this is neither an `untitled` resource, nor a resource + // we can handle with the file service, we can only "Save As..." + if (this.resource.scheme !== Schemas.untitled && !this.fileService.canHandleResource(this.resource)) { + return this.saveAs(group, options); + } + + // Normal save return this.doSave(group, options, false); }