From 9d40b2408c65cb05402bfb6761c28aadb52c3bf7 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 17 Jan 2020 11:56:05 +0100 Subject: [PATCH] untitled - clarify associated resource capabilities --- src/vs/base/common/network.ts | 30 +++++++++---------- .../common/untitledTextEditorService.ts | 21 +++++++++---- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/vs/base/common/network.ts b/src/vs/base/common/network.ts index 231180d513f..a68e020f9f1 100644 --- a/src/vs/base/common/network.ts +++ b/src/vs/base/common/network.ts @@ -12,47 +12,47 @@ export namespace Schemas { * A schema that is used for models that exist in memory * only and that have no correspondence on a server or such. */ - export const inMemory: string = 'inmemory'; + export const inMemory = 'inmemory'; /** * A schema that is used for setting files */ - export const vscode: string = 'vscode'; + export const vscode = 'vscode'; /** * A schema that is used for internal private files */ - export const internal: string = 'private'; + export const internal = 'private'; /** * A walk-through document. */ - export const walkThrough: string = 'walkThrough'; + export const walkThrough = 'walkThrough'; /** * An embedded code snippet. */ - export const walkThroughSnippet: string = 'walkThroughSnippet'; + export const walkThroughSnippet = 'walkThroughSnippet'; - export const http: string = 'http'; + export const http = 'http'; - export const https: string = 'https'; + export const https = 'https'; - export const file: string = 'file'; + export const file = 'file'; - export const mailto: string = 'mailto'; + export const mailto = 'mailto'; - export const untitled: string = 'untitled'; + export const untitled = 'untitled'; - export const data: string = 'data'; + export const data = 'data'; - export const command: string = 'command'; + export const command = 'command'; - export const vscodeRemote: string = 'vscode-remote'; + export const vscodeRemote = 'vscode-remote'; - export const vscodeRemoteResource: string = 'vscode-remote-resource'; + export const vscodeRemoteResource = 'vscode-remote-resource'; - export const userData: string = 'vscode-userdata'; + export const userData = 'vscode-userdata'; } class RemoteAuthoritiesImpl { diff --git a/src/vs/workbench/services/untitled/common/untitledTextEditorService.ts b/src/vs/workbench/services/untitled/common/untitledTextEditorService.ts index a237b772f26..e9d5cc0dc23 100644 --- a/src/vs/workbench/services/untitled/common/untitledTextEditorService.ts +++ b/src/vs/workbench/services/untitled/common/untitledTextEditorService.ts @@ -23,15 +23,20 @@ export interface IUntitledTextEditorOptions { /** * An optional resource to identify the untitled resource to create or return * if already existing. + * + * Note: the resource will not be used unless the scheme is `untitled`. */ untitledResource?: URI; /** - * An optional resource to associate with the untitled file. When saving - * the untitled file, the associated resource will be used and the user + * Optional resource components to associate with the untitled file. When saving + * the untitled file, the associated components will be used and the user * is not being asked to provide a file path. + * + * Note: currently it is not possible to specify the `scheme` to use. The + * untitled file will saved to the default local or remote resource. */ - associatedResource?: URI; + associatedResource?: { authority: string; path: string; query: string; fragment: string; } /** * Initial value of the untitled file. An untitled file with initial @@ -158,7 +163,13 @@ export class UntitledTextEditorService extends Disposable implements IUntitledTe // Figure out associated and untitled resource if (options.associatedResource) { - massagedOptions.untitledResource = options.associatedResource.with({ scheme: Schemas.untitled }); + massagedOptions.untitledResource = URI.from({ + scheme: Schemas.untitled, + authority: options.associatedResource.authority, + fragment: options.associatedResource.fragment, + path: options.associatedResource.path, + query: options.associatedResource.query + }); massagedOptions.associatedResource = options.associatedResource; } else { if (options.untitledResource?.scheme === Schemas.untitled) { @@ -188,7 +199,7 @@ export class UntitledTextEditorService extends Disposable implements IUntitledTe // Create a new untitled resource if none is provided let untitledResource = options.untitledResource; if (!untitledResource) { - let counter = this.mapResourceToInput.size + 1; + let counter = 1; do { untitledResource = URI.from({ scheme: Schemas.untitled, path: `Untitled-${counter}` }); counter++; -- GitLab