Skip to content

Commit

Permalink
editors - allow to save virtual documents (fix #101952)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Sep 7, 2020
1 parent ed9c404 commit 183d11a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/vs/workbench/common/editor/textResourceEditorInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -161,6 +164,14 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput {
}

save(group: GroupIdentifier, options?: ITextFileSaveOptions): Promise<IEditorInput | undefined> {

// 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);
}

Expand Down

0 comments on commit 183d11a

Please sign in to comment.