mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 01:58:53 +01:00
add ICell#uri and expose INotebook#viewType
This commit is contained in:
@@ -41,7 +41,10 @@ export class MainThreadCell implements ICell {
|
||||
this._onDidChangeDirtyState.fire(newState);
|
||||
}
|
||||
|
||||
readonly uri: URI;
|
||||
|
||||
constructor(
|
||||
parent: MainThreadNotebookDocument,
|
||||
public handle: number,
|
||||
public source: string[],
|
||||
public language: string,
|
||||
@@ -49,6 +52,12 @@ export class MainThreadCell implements ICell {
|
||||
outputs: IOutput[]
|
||||
) {
|
||||
this._outputs = outputs;
|
||||
this.uri = URI.from({
|
||||
scheme: 'vscode-notebook',
|
||||
authority: parent.viewType,
|
||||
path: `/cell_${handle}.${cell_type === 'markdown' ? 'md' : 'py'}`,
|
||||
query: parent.uri.toString()
|
||||
});
|
||||
}
|
||||
|
||||
save() {
|
||||
@@ -114,7 +123,7 @@ export class MainThreadNotebookDocument extends Disposable implements INotebook
|
||||
|
||||
if (this.cells.length === 0) {
|
||||
newCells.forEach(cell => {
|
||||
let mainCell = new MainThreadCell(cell.handle, cell.source, cell.language, cell.cell_type, cell.outputs);
|
||||
let mainCell = new MainThreadCell(this, cell.handle, cell.source, cell.language, cell.cell_type, cell.outputs);
|
||||
this._mapping.set(cell.handle, mainCell);
|
||||
this.cells.push(mainCell);
|
||||
let dirtyStateListener = mainCell.onDidChangeDirtyState((cellState) => {
|
||||
@@ -141,7 +150,7 @@ export class MainThreadNotebookDocument extends Disposable implements INotebook
|
||||
async createRawCell(viewType: string, uri: URI, index: number, language: string, type: 'markdown' | 'code'): Promise<MainThreadCell | undefined> {
|
||||
let cell = await this._proxy.$createEmptyCell(viewType, uri, index, language, type);
|
||||
if (cell) {
|
||||
let mainCell = new MainThreadCell(cell.handle, cell.source, cell.language, cell.cell_type, cell.outputs);
|
||||
let mainCell = new MainThreadCell(this, cell.handle, cell.source, cell.language, cell.cell_type, cell.outputs);
|
||||
this._mapping.set(cell.handle, mainCell);
|
||||
this.cells.splice(index, 0, mainCell);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import { ExtHostNotebookShape, IMainContext, MainThreadNotebookShape, MainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostNotebookShape, IMainContext, MainThreadNotebookShape, MainContext, ICellDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { Disposable as VSCodeDisposable } from './extHostTypes';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
@@ -13,7 +13,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { readonly } from 'vs/base/common/errors';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { ICell, INotebookDisplayOrder } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { INotebookDisplayOrder } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
|
||||
interface ExtHostOutputDisplayOrder {
|
||||
defaultOrder: glob.ParsedPattern[];
|
||||
@@ -500,7 +500,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
|
||||
return provider.provider.executeCell(document!, cell);
|
||||
}
|
||||
|
||||
async $createEmptyCell(viewType: string, uri: URI, index: number, language: string, type: 'markdown' | 'code'): Promise<ICell | undefined> {
|
||||
async $createEmptyCell(viewType: string, uri: URI, index: number, language: string, type: 'markdown' | 'code'): Promise<ICellDto | undefined> {
|
||||
let provider = this._notebookProviders.get(viewType);
|
||||
|
||||
if (provider) {
|
||||
|
||||
Reference in New Issue
Block a user