提交 9d40b240 编写于 作者: B Benjamin Pasero

untitled - clarify associated resource capabilities

上级 d63738e1
......@@ -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 {
......
......@@ -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++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册