提交 5b8dc569 编写于 作者: B Benjamin Pasero 提交者: GitHub

Merge pull request #22178 from hoovercj/openWithContentLipstick

Follow up to PR #22021 to respond to feedback
...@@ -100,8 +100,8 @@ suite('workspace-namespace', () => { ...@@ -100,8 +100,8 @@ suite('workspace-namespace', () => {
}); });
}); });
test('openTextDocument, untitled without path but language ID and contents', function () { test('openTextDocument, untitled without path but language ID and content', function () {
return workspace.openTextDocument({ language: 'html', contents: '<h1>Hello world!</h1>' }).then(doc => { return workspace.openTextDocument({ language: 'html', content: '<h1>Hello world!</h1>' }).then(doc => {
assert.equal(doc.uri.scheme, 'untitled'); assert.equal(doc.uri.scheme, 'untitled');
assert.equal(doc.languageId, 'html'); assert.equal(doc.languageId, 'html');
assert.ok(doc.isDirty); assert.ok(doc.isDirty);
......
...@@ -4080,12 +4080,12 @@ declare module 'vscode' { ...@@ -4080,12 +4080,12 @@ declare module 'vscode' {
/** /**
* Opens an untitled text document. The editor will prompt the user for a file * Opens an untitled text document. The editor will prompt the user for a file
* path when the document is to be saved. The `options` parameter allows to * path when the document is to be saved. The `options` parameter allows to
* specify the *language* of the document. * specify the *language* and/or the *content* of the document.
* *
* @param options Options to control how the document will be created. * @param options Options to control how the document will be created.
* @return A promise that resolves to a [document](#TextDocument). * @return A promise that resolves to a [document](#TextDocument).
*/ */
export function openTextDocument(options?: { language?: string; contents?: string; }): Thenable<TextDocument>; export function openTextDocument(options?: { language?: string; content?: string; }): Thenable<TextDocument>;
/** /**
* Register a text document content provider. * Register a text document content provider.
......
...@@ -368,10 +368,10 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ ...@@ -368,10 +368,10 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ
set textDocuments(value) { set textDocuments(value) {
throw errors.readonly(); throw errors.readonly();
}, },
openTextDocument(uriOrFileNameOrOptions?: vscode.Uri | string | { language?: string; contents?: string; }) { openTextDocument(uriOrFileNameOrOptions?: vscode.Uri | string | { language?: string; content?: string; }) {
let uriPromise: TPromise<URI>; let uriPromise: TPromise<URI>;
let options = uriOrFileNameOrOptions as { language?: string; contents?: string; }; let options = uriOrFileNameOrOptions as { language?: string; content?: string; };
if (!options || typeof options.language === 'string') { if (!options || typeof options.language === 'string') {
uriPromise = extHostDocuments.createDocumentData(options); uriPromise = extHostDocuments.createDocumentData(options);
} else if (typeof uriOrFileNameOrOptions === 'string') { } else if (typeof uriOrFileNameOrOptions === 'string') {
......
...@@ -120,7 +120,7 @@ export abstract class MainThreadDiagnosticsShape { ...@@ -120,7 +120,7 @@ export abstract class MainThreadDiagnosticsShape {
} }
export abstract class MainThreadDocumentsShape { export abstract class MainThreadDocumentsShape {
$tryCreateDocument(options?: { language?: string; contents?: string; }): TPromise<any> { throw ni(); } $tryCreateDocument(options?: { language?: string; content?: string; }): TPromise<any> { throw ni(); }
$tryOpenDocument(uri: URI): TPromise<any> { throw ni(); } $tryOpenDocument(uri: URI): TPromise<any> { throw ni(); }
$registerTextContentProvider(handle: number, scheme: string): void { throw ni(); } $registerTextContentProvider(handle: number, scheme: string): void { throw ni(); }
$onVirtualDocumentChange(uri: URI, value: ITextSource): void { throw ni(); } $onVirtualDocumentChange(uri: URI, value: ITextSource): void { throw ni(); }
......
...@@ -101,7 +101,7 @@ export class ExtHostDocuments extends ExtHostDocumentsShape { ...@@ -101,7 +101,7 @@ export class ExtHostDocuments extends ExtHostDocumentsShape {
return promise; return promise;
} }
public createDocumentData(options?: { language?: string; contents?: string }): TPromise<URI> { public createDocumentData(options?: { language?: string; content?: string }): TPromise<URI> {
return this._proxy.$tryCreateDocument(options); return this._proxy.$tryCreateDocument(options);
} }
......
...@@ -228,8 +228,8 @@ export class MainThreadDocuments extends MainThreadDocumentsShape { ...@@ -228,8 +228,8 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
}); });
} }
$tryCreateDocument(options?: { language?: string, contents?: string }): TPromise<URI> { $tryCreateDocument(options?: { language?: string, content?: string }): TPromise<URI> {
return this._doCreateUntitled(void 0, options ? options.language : void 0, options ? options.contents : void 0); return this._doCreateUntitled(void 0, options ? options.language : void 0, options ? options.content : void 0);
} }
private _handleAsResourceInput(uri: URI): TPromise<boolean> { private _handleAsResourceInput(uri: URI): TPromise<boolean> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册