Merge branch 'notebook/dev' into joh/kernel-push
This commit is contained in:
commit
d38cfa11d8
3 changed files with 26 additions and 21 deletions
13
src/vs/vscode.proposed.d.ts
vendored
13
src/vs/vscode.proposed.d.ts
vendored
|
@ -1198,8 +1198,11 @@ declare module 'vscode' {
|
|||
|
||||
export interface NotebookCellsChangeData {
|
||||
readonly start: number;
|
||||
// todo@API end? Use NotebookCellRange instead?
|
||||
readonly deletedCount: number;
|
||||
// todo@API removedCells, deletedCells?
|
||||
readonly deletedItems: NotebookCell[];
|
||||
// todo@API addedCells, insertedCells, newCells?
|
||||
readonly items: NotebookCell[];
|
||||
}
|
||||
|
||||
|
@ -1221,16 +1224,6 @@ declare module 'vscode' {
|
|||
readonly cells: NotebookCell[];
|
||||
}
|
||||
|
||||
export interface NotebookCellLanguageChangeEvent {
|
||||
|
||||
/**
|
||||
* The affected document.
|
||||
*/
|
||||
readonly document: NotebookDocument;
|
||||
readonly cell: NotebookCell;
|
||||
readonly language: string;
|
||||
}
|
||||
|
||||
export interface NotebookCellMetadataChangeEvent {
|
||||
readonly document: NotebookDocument;
|
||||
readonly cell: NotebookCell;
|
||||
|
|
|
@ -226,7 +226,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
|||
metadata: NotebookDocumentMetadata,
|
||||
options: TransientOptions,
|
||||
@IUndoRedoService private readonly _undoService: IUndoRedoService,
|
||||
@IModelService _modelService: IModelService,
|
||||
@IModelService private readonly _modelService: IModelService,
|
||||
@IModeService private readonly _modeService: IModeService,
|
||||
) {
|
||||
super();
|
||||
|
@ -308,6 +308,20 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
|||
return this.cells.findIndex(c => !!c.outputs.find(o => o.outputId === outputId));
|
||||
}
|
||||
|
||||
reset(cells: ICellDto2[], metadata: NotebookDocumentMetadata, transientOptions: TransientOptions): void {
|
||||
this.transientOptions = transientOptions;
|
||||
this._cellhandlePool = 0;
|
||||
this.applyEdits(
|
||||
[
|
||||
{ editType: CellEditType.Replace, index: 0, count: this.cells.length, cells },
|
||||
{ editType: CellEditType.DocumentMetadata, metadata }
|
||||
],
|
||||
true,
|
||||
undefined, () => undefined,
|
||||
undefined
|
||||
);
|
||||
}
|
||||
|
||||
applyEdits(rawEdits: ICellEditOperation[], synchronous: boolean, beginSelectionState: ISelectionState | undefined, endSelectionsComputer: () => ISelectionState | undefined, undoRedoGroup: UndoRedoGroup | undefined, computeUndoRedo: boolean = true): boolean {
|
||||
|
||||
this._eventEmitter.beginDeferredEmit();
|
||||
|
@ -435,6 +449,11 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
|||
cellDto.source, cellDto.language, cellDto.cellKind, cellDto.outputs || [], cellDto.metadata, this.transientOptions,
|
||||
this._modeService
|
||||
);
|
||||
const textModel = this._modelService.getModel(cellUri);
|
||||
if (textModel) {
|
||||
cell.textModel = textModel;
|
||||
cell.language = cellDto.language;
|
||||
}
|
||||
const dirtyStateListener = cell.onDidChangeContent(() => {
|
||||
this._increaseVersionId();
|
||||
this._eventEmitter.emit({ kind: NotebookCellsChangeType.ChangeCellContent, transient: false }, true);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import * as nls from 'vs/nls';
|
||||
import { EditorModel, IEditorInput, IRevertOptions, ISaveOptions } from 'vs/workbench/common/editor';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { CellEditType, ICellEditOperation, INotebookEditorModel, INotebookLoadOptions, IResolvedNotebookEditorModel, NotebookCellsChangeType, NotebookDataDto, NotebookDocumentBackupData } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { INotebookEditorModel, INotebookLoadOptions, IResolvedNotebookEditorModel, NotebookCellsChangeType, NotebookDataDto, NotebookDocumentBackupData } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
|
||||
import { IMainNotebookController, INotebookSerializer, INotebookService, SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
@ -239,10 +239,7 @@ export class ComplexNotebookEditorModel extends EditorModel implements INotebook
|
|||
} else {
|
||||
// UPDATE exitsing notebook with data that we have just fetched
|
||||
this._logService.debug('[notebook editor model] loading onto EXISTING notebook', this.resource.toString());
|
||||
this.notebook.metadata = data.data.metadata;
|
||||
this.notebook.transientOptions = data.transientOptions;
|
||||
const edits: ICellEditOperation[] = [{ editType: CellEditType.Replace, index: 0, count: this.notebook.cells.length, cells: data.data.cells }];
|
||||
this.notebook.applyEdits(edits, true, undefined, () => undefined, undefined);
|
||||
this.notebook.reset(data.data.cells, data.data.metadata, data.transientOptions);
|
||||
}
|
||||
|
||||
if (backupId) {
|
||||
|
@ -532,11 +529,7 @@ export class NotebookFileWorkingCopyModel implements IFileWorkingCopyModel {
|
|||
if (token.isCancellationRequested) {
|
||||
throw canceled();
|
||||
}
|
||||
|
||||
this._notebookModel.metadata = data.metadata;
|
||||
this._notebookModel.transientOptions = this._notebookSerializer.options;
|
||||
const edits: ICellEditOperation[] = [{ editType: CellEditType.Replace, index: 0, count: this._notebookModel.cells.length, cells: data.cells }];
|
||||
this._notebookModel.applyEdits(edits, true, undefined, () => undefined, undefined, false);
|
||||
this._notebookModel.reset(data.cells, data.metadata, this._notebookSerializer.options);
|
||||
}
|
||||
|
||||
get versionId() { return this._notebookModel.alternativeVersionId; }
|
||||
|
|
Loading…
Reference in a new issue