mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-29 00:46:00 +01:00
remove onDidChangeMetadata.
This commit is contained in:
@@ -333,7 +333,7 @@ export class ExtHostNotebookDocument extends Disposable {
|
||||
this._clearAllCellOutputs();
|
||||
} else if (event.kind === NotebookCellsChangeType.ChangeLanguage) {
|
||||
this._changeCellLanguage(event.index, event.language);
|
||||
} else if (event.kind === NotebookCellsChangeType.ChangeMetadata) {
|
||||
} else if (event.kind === NotebookCellsChangeType.ChangeCellMetadata) {
|
||||
this._changeCellMetadata(event.index, event.metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import { NotebookEventDispatcher, NotebookMetadataChangedEvent } from 'vs/workbe
|
||||
import { CellFoldingState, EditorFoldingStateDelegate } from 'vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel';
|
||||
import { MarkdownCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel';
|
||||
import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel';
|
||||
import { CellKind, NotebookCellMetadata, INotebookSearchOptions, ICellRange } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { CellKind, NotebookCellMetadata, INotebookSearchOptions, ICellRange, NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { FoldingRegions } from 'vs/editor/contrib/folding/foldingRanges';
|
||||
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
|
||||
import { MarkdownRenderer } from 'vs/workbench/contrib/notebook/browser/view/renderers/mdRenderer';
|
||||
@@ -308,8 +308,10 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
|
||||
this.selectionHandles = endSelectionHandles;
|
||||
}));
|
||||
|
||||
this._register(this._notebook.onDidChangeMetadata(e => {
|
||||
this.eventDispatcher.emit([new NotebookMetadataChangedEvent(e)]);
|
||||
this._register(this._notebook.onDidChangeContent(e => {
|
||||
if (e === NotebookCellsChangeType.ChangeDocumentMetadata) {
|
||||
this.eventDispatcher.emit([new NotebookMetadataChangedEvent(this._notebook.metadata)]);
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(this._notebook.emitSelections(selections => {
|
||||
|
||||
@@ -118,10 +118,8 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
get emitSelections() { return this._emitSelections.event; }
|
||||
private _onDidModelChangeProxy = this._register(new Emitter<NotebookCellsChangedEvent>());
|
||||
get onDidModelChangeProxy(): Event<NotebookCellsChangedEvent> { return this._onDidModelChangeProxy.event; }
|
||||
private _onDidChangeContent = this._register(new Emitter<void>());
|
||||
onDidChangeContent: Event<void> = this._onDidChangeContent.event;
|
||||
private _onDidChangeMetadata = this._register(new Emitter<NotebookDocumentMetadata>());
|
||||
onDidChangeMetadata: Event<NotebookDocumentMetadata> = this._onDidChangeMetadata.event;
|
||||
private _onDidChangeContent = this._register(new Emitter<NotebookCellsChangeType | undefined>());
|
||||
onDidChangeContent: Event<NotebookCellsChangeType | undefined> = this._onDidChangeContent.event;
|
||||
private _mapping: Map<number, NotebookCellTextModel> = new Map();
|
||||
private _cellListeners: Map<number, IDisposable> = new Map();
|
||||
cells: NotebookCellTextModel[];
|
||||
@@ -210,7 +208,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
const dirtyStateListener = mainCells[i].onDidChangeContent(() => {
|
||||
this.setDirty(true);
|
||||
this._increaseVersionId();
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeCellContent);
|
||||
});
|
||||
|
||||
this._cellListeners.set(mainCells[i].handle, dirtyStateListener);
|
||||
@@ -324,7 +322,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
const dirtyStateListener = cell.onDidChangeContent(() => {
|
||||
this.setDirty(true);
|
||||
this._increaseVersionId();
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeCellContent);
|
||||
});
|
||||
this._cellListeners.set(cell.handle, dirtyStateListener);
|
||||
this._mapping.set(cell.handle, cell);
|
||||
@@ -335,7 +333,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
this.cells.splice(index, count, ...cells);
|
||||
this.setDirty(true);
|
||||
this._increaseVersionId();
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.ModelChange);
|
||||
}
|
||||
|
||||
handleEdit(label: string | undefined, undo: () => void, redo: () => void): void {
|
||||
@@ -378,7 +376,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
|
||||
updateNotebookMetadata(metadata: NotebookDocumentMetadata) {
|
||||
this.metadata = metadata;
|
||||
this._onDidChangeMetadata.fire(this.metadata);
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeDocumentMetadata);
|
||||
}
|
||||
|
||||
insertTemplateCell(cell: NotebookCellTextModel) {
|
||||
@@ -394,12 +392,12 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
this._isUntitled = false;
|
||||
this.setDirty(true);
|
||||
this._increaseVersionId();
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeCellContent);
|
||||
});
|
||||
|
||||
this._cellListeners.set(cell.handle, dirtyStateListener);
|
||||
this.setDirty(false);
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.ModelChange);
|
||||
|
||||
this._onDidModelChangeProxy.fire({
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -431,7 +429,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
const dirtyStateListener = cells[i].onDidChangeContent(() => {
|
||||
this.setDirty(true);
|
||||
this._increaseVersionId();
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeCellContent);
|
||||
});
|
||||
|
||||
this._cellListeners.set(cells[i].handle, dirtyStateListener);
|
||||
@@ -439,7 +437,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
|
||||
this.cells.splice(index, 0, ...cells);
|
||||
this.setDirty(true);
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.ModelChange);
|
||||
|
||||
this._increaseVersionId();
|
||||
|
||||
@@ -475,7 +473,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
}
|
||||
this.cells.splice(index, count);
|
||||
this.setDirty(true);
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.ModelChange);
|
||||
|
||||
this._increaseVersionId();
|
||||
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.ModelChange, versionId: this._versionId, changes: [[index, count, []]] });
|
||||
@@ -488,7 +486,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
const cells = this.cells.splice(index, length);
|
||||
this.cells.splice(newIdx, 0, ...cells);
|
||||
this.setDirty(true);
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.Move);
|
||||
|
||||
this._increaseVersionId();
|
||||
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.Move, versionId: this._versionId, index, newIdx });
|
||||
@@ -510,7 +508,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
if (!this.transientOptions.transientOutputs) {
|
||||
this._increaseVersionId();
|
||||
this.setDirty(true);
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.Output);
|
||||
}
|
||||
|
||||
this._onDidModelChangeProxy.fire({
|
||||
@@ -585,13 +583,13 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
}
|
||||
cell.metadata = metadata;
|
||||
this.setDirty(true);
|
||||
this._onDidChangeContent.fire();
|
||||
this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeCellMetadata);
|
||||
} else {
|
||||
cell.metadata = metadata;
|
||||
}
|
||||
|
||||
this._increaseVersionId();
|
||||
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.ChangeMetadata, versionId: this._versionId, index: this.cells.indexOf(cell), metadata: cell.metadata });
|
||||
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.ChangeCellMetadata, versionId: this._versionId, index: this.cells.indexOf(cell), metadata: cell.metadata });
|
||||
}
|
||||
|
||||
deltaCellMetadata(handle: number, newMetadata: NotebookCellMetadata) {
|
||||
|
||||
@@ -278,7 +278,7 @@ export interface INotebookTextModel {
|
||||
languages: string[];
|
||||
cells: ICell[];
|
||||
onDidChangeCells?: Event<{ synchronous: boolean, splices: NotebookCellTextModelSplice[] }>;
|
||||
onDidChangeContent: Event<void>;
|
||||
onDidChangeContent: Event<NotebookCellsChangeType | undefined>;
|
||||
onWillDispose(listener: () => void): IDisposable;
|
||||
}
|
||||
|
||||
@@ -348,8 +348,10 @@ export enum NotebookCellsChangeType {
|
||||
CellsClearOutput = 4,
|
||||
ChangeLanguage = 5,
|
||||
Initialize = 6,
|
||||
ChangeMetadata = 7,
|
||||
ChangeCellMetadata = 7,
|
||||
Output = 8,
|
||||
ChangeCellContent = 9,
|
||||
ChangeDocumentMetadata = 10
|
||||
}
|
||||
|
||||
export interface NotebookCellsInitializeEvent {
|
||||
@@ -358,6 +360,11 @@ export interface NotebookCellsInitializeEvent {
|
||||
readonly versionId: number;
|
||||
}
|
||||
|
||||
export interface NotebookCellContentChangeEvent {
|
||||
readonly kind: NotebookCellsChangeType.ChangeCellContent;
|
||||
readonly versionId: number;
|
||||
}
|
||||
|
||||
export interface NotebookCellsModelChangedEvent {
|
||||
readonly kind: NotebookCellsChangeType.ModelChange;
|
||||
readonly changes: NotebookCellsSplice2[];
|
||||
@@ -397,13 +404,19 @@ export interface NotebookCellsChangeLanguageEvent {
|
||||
}
|
||||
|
||||
export interface NotebookCellsChangeMetadataEvent {
|
||||
readonly kind: NotebookCellsChangeType.ChangeMetadata;
|
||||
readonly kind: NotebookCellsChangeType.ChangeCellMetadata;
|
||||
readonly versionId: number;
|
||||
readonly index: number;
|
||||
readonly metadata: NotebookCellMetadata | undefined;
|
||||
}
|
||||
|
||||
export type NotebookCellsChangedEvent = NotebookCellsInitializeEvent | NotebookCellsModelChangedEvent | NotebookCellsModelMoveEvent | NotebookOutputChangedEvent | NotebookCellClearOutputEvent | NotebookCellsClearOutputEvent | NotebookCellsChangeLanguageEvent | NotebookCellsChangeMetadataEvent;
|
||||
export interface NotebookDocumentChangeMetadataEvent {
|
||||
readonly kind: NotebookCellsChangeType.ChangeDocumentMetadata;
|
||||
readonly versionId: number;
|
||||
readonly metadata: NotebookDocumentMetadata | undefined;
|
||||
}
|
||||
|
||||
export type NotebookCellsChangedEvent = NotebookCellsInitializeEvent | NotebookDocumentChangeMetadataEvent | NotebookCellContentChangeEvent | NotebookCellsModelChangedEvent | NotebookCellsModelMoveEvent | NotebookOutputChangedEvent | NotebookCellClearOutputEvent | NotebookCellsClearOutputEvent | NotebookCellsChangeLanguageEvent | NotebookCellsChangeMetadataEvent;
|
||||
|
||||
export const enum CellEditType {
|
||||
Replace = 1,
|
||||
|
||||
Reference in New Issue
Block a user