Skip to content

Commit 9d40b24

Browse files
author
Benjamin Pasero
committed
untitled - clarify associated resource capabilities
1 parent d63738e commit 9d40b24

2 files changed

Lines changed: 31 additions & 20 deletions

File tree

src/vs/base/common/network.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,47 @@ export namespace Schemas {
1212
* A schema that is used for models that exist in memory
1313
* only and that have no correspondence on a server or such.
1414
*/
15-
export const inMemory: string = 'inmemory';
15+
export const inMemory = 'inmemory';
1616

1717
/**
1818
* A schema that is used for setting files
1919
*/
20-
export const vscode: string = 'vscode';
20+
export const vscode = 'vscode';
2121

2222
/**
2323
* A schema that is used for internal private files
2424
*/
25-
export const internal: string = 'private';
25+
export const internal = 'private';
2626

2727
/**
2828
* A walk-through document.
2929
*/
30-
export const walkThrough: string = 'walkThrough';
30+
export const walkThrough = 'walkThrough';
3131

3232
/**
3333
* An embedded code snippet.
3434
*/
35-
export const walkThroughSnippet: string = 'walkThroughSnippet';
35+
export const walkThroughSnippet = 'walkThroughSnippet';
3636

37-
export const http: string = 'http';
37+
export const http = 'http';
3838

39-
export const https: string = 'https';
39+
export const https = 'https';
4040

41-
export const file: string = 'file';
41+
export const file = 'file';
4242

43-
export const mailto: string = 'mailto';
43+
export const mailto = 'mailto';
4444

45-
export const untitled: string = 'untitled';
45+
export const untitled = 'untitled';
4646

47-
export const data: string = 'data';
47+
export const data = 'data';
4848

49-
export const command: string = 'command';
49+
export const command = 'command';
5050

51-
export const vscodeRemote: string = 'vscode-remote';
51+
export const vscodeRemote = 'vscode-remote';
5252

53-
export const vscodeRemoteResource: string = 'vscode-remote-resource';
53+
export const vscodeRemoteResource = 'vscode-remote-resource';
5454

55-
export const userData: string = 'vscode-userdata';
55+
export const userData = 'vscode-userdata';
5656
}
5757

5858
class RemoteAuthoritiesImpl {

src/vs/workbench/services/untitled/common/untitledTextEditorService.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,20 @@ export interface IUntitledTextEditorOptions {
2323
/**
2424
* An optional resource to identify the untitled resource to create or return
2525
* if already existing.
26+
*
27+
* Note: the resource will not be used unless the scheme is `untitled`.
2628
*/
2729
untitledResource?: URI;
2830

2931
/**
30-
* An optional resource to associate with the untitled file. When saving
31-
* the untitled file, the associated resource will be used and the user
32+
* Optional resource components to associate with the untitled file. When saving
33+
* the untitled file, the associated components will be used and the user
3234
* is not being asked to provide a file path.
35+
*
36+
* Note: currently it is not possible to specify the `scheme` to use. The
37+
* untitled file will saved to the default local or remote resource.
3338
*/
34-
associatedResource?: URI;
39+
associatedResource?: { authority: string; path: string; query: string; fragment: string; }
3540

3641
/**
3742
* Initial value of the untitled file. An untitled file with initial
@@ -158,7 +163,13 @@ export class UntitledTextEditorService extends Disposable implements IUntitledTe
158163

159164
// Figure out associated and untitled resource
160165
if (options.associatedResource) {
161-
massagedOptions.untitledResource = options.associatedResource.with({ scheme: Schemas.untitled });
166+
massagedOptions.untitledResource = URI.from({
167+
scheme: Schemas.untitled,
168+
authority: options.associatedResource.authority,
169+
fragment: options.associatedResource.fragment,
170+
path: options.associatedResource.path,
171+
query: options.associatedResource.query
172+
});
162173
massagedOptions.associatedResource = options.associatedResource;
163174
} else {
164175
if (options.untitledResource?.scheme === Schemas.untitled) {
@@ -188,7 +199,7 @@ export class UntitledTextEditorService extends Disposable implements IUntitledTe
188199
// Create a new untitled resource if none is provided
189200
let untitledResource = options.untitledResource;
190201
if (!untitledResource) {
191-
let counter = this.mapResourceToInput.size + 1;
202+
let counter = 1;
192203
do {
193204
untitledResource = URI.from({ scheme: Schemas.untitled, path: `Untitled-${counter}` });
194205
counter++;

0 commit comments

Comments
 (0)