fix #108406. openNotebookDocument.

This commit is contained in:
rebornix
2020-10-09 11:18:21 -07:00
parent ec83474a0f
commit 2249f2aba5
5 changed files with 79 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ import { ExtHostCell, ExtHostNotebookDocument } from './extHostNotebookDocument'
import { ExtHostNotebookEditor } from './extHostNotebookEditor';
import { IdGenerator } from 'vs/base/common/idGenerator';
import { IRelativePattern } from 'vs/base/common/glob';
import { assertIsDefined } from 'vs/base/common/types';
class ExtHostWebviewCommWrapper extends Disposable {
private readonly _onDidReceiveDocumentMessage = new Emitter<any>();
@@ -386,6 +387,17 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
return new NotebookEditorDecorationType(this._proxy, options);
}
async openNotebookDocument(uriComponents: UriComponents, viewType?: string): Promise<vscode.NotebookDocument> {
const cached = this._documents.get(URI.revive(uriComponents));
if (cached) {
return Promise.resolve(cached.notebookDocument);
}
await this._proxy.$tryOpenDocument(uriComponents, viewType);
const document = this._documents.get(URI.revive(uriComponents));
return assertIsDefined(document?.notebookDocument);
}
private _withAdapter<T>(handle: number, uri: UriComponents, callback: (adapter: ExtHostNotebookKernelProviderAdapter, document: ExtHostNotebookDocument) => Promise<T>) {
const document = this._documents.get(URI.revive(uri));