提交 17d779cf 编写于 作者: R rebornix

unified onDidChangeContent

上级 a98552c9
......@@ -279,7 +279,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
if (!this._editorEventListenersMapping.has(doc.toString())) {
const disposableStore = new DisposableStore();
const textModel = this._notebookService.getNotebookTextModel(doc);
disposableStore.add(textModel!.onDidModelChangeProxy(e => {
disposableStore.add(textModel!.onDidChangeContent(e => {
const data =
e.kind === NotebookCellsChangeType.ModelChange || e.kind === NotebookCellsChangeType.Initialize
? {
......
......@@ -43,7 +43,7 @@ export class SCMController extends Disposable implements INotebookEditorContribu
this.update();
if (this._notebookEditor.textModel) {
this._localDisposable.add(this._notebookEditor.textModel.onDidModelChangeProxy((e) => {
this._localDisposable.add(this._notebookEditor.textModel.onDidChangeContent((e) => {
this.update();
}));
}
......
......@@ -308,7 +308,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
this.selectionHandles = endSelectionHandles;
};
this._register(this._notebook.onDidModelChangeProxy(e => {
this._register(this._notebook.onDidChangeContent(e => {
let changes: NotebookCellTextModelSplice<ICell>[] = [];
if (e.kind === NotebookCellsChangeType.ModelChange || e.kind === NotebookCellsChangeType.Initialize) {
......@@ -323,7 +323,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
}
}));
this._register(this._notebook.onDidModelChangeProxy(e => {
this._register(this._notebook.onDidChangeContent(e => {
if (e.kind === NotebookCellsChangeType.ChangeDocumentMetadata) {
this.eventDispatcher.emit([new NotebookMetadataChangedEvent(this._notebook.metadata)]);
}
......
......@@ -149,8 +149,8 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
readonly onDidChangeDirty = this._onDidChangeDirty.event;
private readonly _emitSelections = this._register(new Emitter<number[]>());
get emitSelections() { return this._emitSelections.event; }
private _onDidModelChangeProxy = this._register(new Emitter<NotebookTextModelChangedEvent>());
get onDidModelChangeProxy(): Event<NotebookTextModelChangedEvent> { return this._onDidModelChangeProxy.event; }
private _onDidChangeContent = this._register(new Emitter<NotebookTextModelChangedEvent>());
get onDidChangeContent(): Event<NotebookTextModelChangedEvent> { return this._onDidChangeContent.event; }
private _mapping: Map<number, NotebookCellTextModel> = new Map();
private _cellListeners: Map<number, IDisposable> = new Map();
cells: NotebookCellTextModel[];
......@@ -195,7 +195,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
this._operationManager = new NotebookOperationManager(this._undoService, uri);
this._eventEmitter = new DelayedEmitter(
this._onDidModelChangeProxy,
this._onDidChangeContent,
() => { this._increaseVersionId(); },
this
);
......@@ -242,7 +242,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
this.setDirty(true);
this._increaseVersionId();
// this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeCellContent);
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.ChangeCellContent, versionId: this.versionId, synchronous: true });
this._onDidChangeContent.fire({ kind: NotebookCellsChangeType.ChangeCellContent, versionId: this.versionId, synchronous: true });
});
this._cellListeners.set(mainCells[i].handle, dirtyStateListener);
......@@ -333,7 +333,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
this.setDirty(true);
this._increaseVersionId();
// this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeCellContent);
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.ChangeCellContent, versionId: this.versionId, synchronous: true });
this._onDidChangeContent.fire({ kind: NotebookCellsChangeType.ChangeCellContent, versionId: this.versionId, synchronous: true });
});
this._cellListeners.set(cell.handle, dirtyStateListener);
......@@ -417,7 +417,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
updateNotebookMetadata(metadata: NotebookDocumentMetadata) {
this.metadata = metadata;
// this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeDocumentMetadata);
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.ChangeDocumentMetadata, versionId: this.versionId, metadata: this.metadata, synchronous: true });
this._onDidChangeContent.fire({ kind: NotebookCellsChangeType.ChangeDocumentMetadata, versionId: this.versionId, metadata: this.metadata, synchronous: true });
}
......@@ -435,7 +435,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
this.setDirty(true);
this._increaseVersionId();
// this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeCellContent);
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.ChangeCellContent, versionId: this.versionId, synchronous: true });
this._onDidChangeContent.fire({ kind: NotebookCellsChangeType.ChangeCellContent, versionId: this.versionId, synchronous: true });
});
......@@ -443,7 +443,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
this.setDirty(false);
// this._onDidChangeContent.fire(NotebookCellsChangeType.ModelChange);
this._onDidModelChangeProxy.fire({
this._onDidChangeContent.fire({
kind: NotebookCellsChangeType.ModelChange,
versionId: this._versionId, changes:
[[
......@@ -466,7 +466,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
this.setDirty(true);
this._increaseVersionId();
// this._onDidChangeContent.fire(NotebookCellsChangeType.ChangeCellContent);
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.ChangeCellContent, versionId: this.versionId, synchronous: true });
this._onDidChangeContent.fire({ kind: NotebookCellsChangeType.ChangeCellContent, versionId: this.versionId, synchronous: true });
});
this._cellListeners.set(cells[i].handle, dirtyStateListener);
......@@ -478,7 +478,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
this._increaseVersionId();
this._onDidModelChangeProxy.fire({
this._onDidChangeContent.fire({
kind: NotebookCellsChangeType.ModelChange,
versionId: this._versionId, changes:
[[
......@@ -505,7 +505,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
// this._onDidChangeContent.fire(NotebookCellsChangeType.ModelChange);
this._increaseVersionId();
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.ModelChange, versionId: this._versionId, changes: [[index, count, []]], synchronous });
this._onDidChangeContent.fire({ kind: NotebookCellsChangeType.ModelChange, versionId: this._versionId, changes: [[index, count, []]], synchronous });
}
private _isCellMetadataChanged(a: NotebookCellMetadata, b: NotebookCellMetadata) {
......@@ -599,7 +599,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
cell.language = languageId;
this._increaseVersionId();
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.ChangeLanguage, versionId: this._versionId, index: this.cells.indexOf(cell), language: languageId, synchronous: true });
this._onDidChangeContent.fire({ kind: NotebookCellsChangeType.ChangeLanguage, versionId: this._versionId, index: this.cells.indexOf(cell), language: languageId, synchronous: true });
}
}
......@@ -655,7 +655,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
// this._onDidChangeContent.fire(NotebookCellsChangeType.Move);
this._increaseVersionId();
this._onDidModelChangeProxy.fire({ kind: NotebookCellsChangeType.Move, versionId: this._versionId, index, length, newIdx, cells, synchronous });
this._onDidChangeContent.fire({ kind: NotebookCellsChangeType.Move, versionId: this._versionId, index, length, newIdx, cells, synchronous });
}
// todo, we can't emit this change as it will create a new view model and that will hold
......
......@@ -145,7 +145,7 @@ export class NotebookEditorModel extends EditorModel implements INotebookEditorM
this._register(this._notebook);
this._register(this._notebook.onDidModelChangeProxy(e => {
this._register(this._notebook.onDidChangeContent(e => {
if (e.kind !== NotebookCellsChangeType.Initialize) {
this._onDidChangeContent.fire();
}
......
......@@ -337,8 +337,8 @@ export class NotebookEditorTestModel extends EditorModel implements INotebookEdi
) {
super();
if (_notebook && _notebook.onDidModelChangeProxy) {
this._register(_notebook.onDidModelChangeProxy(() => {
if (_notebook && _notebook.onDidChangeContent) {
this._register(_notebook.onDidChangeContent(() => {
this._dirty = true;
this._onDidChangeDirty.fire();
this._onDidChangeContent.fire();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册