mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
A single model content changed events contains the list of changes
This commit is contained in:
@@ -38,7 +38,7 @@ import { IApplyEditsOptions, IUndoStopOptions, TextEditorRevealType, ITextEditor
|
||||
|
||||
import { InternalTreeExplorerNodeContent } from 'vs/workbench/parts/explorers/common/treeExplorerViewModel';
|
||||
import { TaskSet } from 'vs/workbench/parts/tasks/common/tasks';
|
||||
import { IModelChangedData } from 'vs/editor/common/model/mirrorModel2';
|
||||
import { IModelChangedEvent } from 'vs/editor/common/model/mirrorModel2';
|
||||
|
||||
export interface IEnvironment {
|
||||
enableProposedApi: boolean;
|
||||
@@ -313,7 +313,7 @@ export abstract class ExtHostDocumentsShape {
|
||||
$acceptModelSaved(strURL: string): void { throw ni(); }
|
||||
$acceptModelDirty(strURL: string): void { throw ni(); }
|
||||
$acceptModelReverted(strURL: string): void { throw ni(); }
|
||||
$acceptModelChanged(strURL: string, events: IModelChangedData[], isDirty: boolean): void { throw ni(); }
|
||||
$acceptModelChanged(strURL: string, e: IModelChangedEvent, isDirty: boolean): void { throw ni(); }
|
||||
}
|
||||
|
||||
export abstract class ExtHostDocumentSaveParticipantShape {
|
||||
|
||||
@@ -19,7 +19,7 @@ import { TextSource } from 'vs/editor/common/model/textSource';
|
||||
import { MainContext, MainThreadDocumentsShape, ExtHostDocumentsShape } from './extHost.protocol';
|
||||
import { ExtHostDocumentData, setWordDefinitionFor } from './extHostDocumentData';
|
||||
import { ExtHostDocumentsAndEditors } from './extHostDocumentsAndEditors';
|
||||
import { IModelChangedData } from 'vs/editor/common/model/mirrorModel2';
|
||||
import { IModelChangedEvent } from 'vs/editor/common/model/mirrorModel2';
|
||||
|
||||
export class ExtHostDocuments extends ExtHostDocumentsShape {
|
||||
|
||||
@@ -185,17 +185,17 @@ export class ExtHostDocuments extends ExtHostDocumentsShape {
|
||||
document._acceptIsDirty(false);
|
||||
}
|
||||
|
||||
public $acceptModelChanged(strURL: string, events: IModelChangedData[], isDirty: boolean): void {
|
||||
public $acceptModelChanged(strURL: string, events: IModelChangedEvent, isDirty: boolean): void {
|
||||
let data = this._documentsAndEditors.getDocument(strURL);
|
||||
data._acceptIsDirty(isDirty);
|
||||
data.onEvents(events);
|
||||
this._onDidChangeDocument.fire({
|
||||
document: data.document,
|
||||
contentChanges: events.map((e) => {
|
||||
contentChanges: events.changes.map((change) => {
|
||||
return {
|
||||
range: TypeConverters.toRange(e.range),
|
||||
rangeLength: e.rangeLength,
|
||||
text: e.text
|
||||
range: TypeConverters.toRange(change.range),
|
||||
rangeLength: change.rangeLength,
|
||||
text: change.text
|
||||
};
|
||||
})
|
||||
});
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { EmitterEvent } from 'vs/base/common/eventEmitter';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import { IDisposable, dispose, IReference } from 'vs/base/common/lifecycle';
|
||||
@@ -158,7 +157,9 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
|
||||
}
|
||||
let modelUrl = model.uri;
|
||||
this._modelIsSynced[modelUrl.toString()] = true;
|
||||
this._modelToDisposeMap[modelUrl.toString()] = model.addBulkListener((events) => this._onModelEvents(modelUrl, events));
|
||||
this._modelToDisposeMap[modelUrl.toString()] = model.onDidChangeContent((e) => {
|
||||
this._proxy.$acceptModelChanged(modelUrl.toString(), e, this._textFileService.isDirty(modelUrl));
|
||||
});
|
||||
}
|
||||
|
||||
private _onModelModeChanged(event: { model: editorCommon.IModel; oldModeId: string; }): void {
|
||||
@@ -180,21 +181,6 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
|
||||
delete this._modelToDisposeMap[modelUrl];
|
||||
}
|
||||
|
||||
private _onModelEvents(modelUrl: URI, events: EmitterEvent[]): void {
|
||||
let changedEvents: editorCommon.IModelContentChangedEvent2[] = [];
|
||||
for (let i = 0, len = events.length; i < len; i++) {
|
||||
let e = events[i];
|
||||
switch (e.getType()) {
|
||||
case editorCommon.EventType.ModelContentChanged2:
|
||||
changedEvents.push(<editorCommon.IModelContentChangedEvent2>e.getData());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (changedEvents.length > 0) {
|
||||
this._proxy.$acceptModelChanged(modelUrl.toString(), changedEvents, this._textFileService.isDirty(modelUrl));
|
||||
}
|
||||
}
|
||||
|
||||
// --- from extension host process
|
||||
|
||||
$trySaveDocument(uri: URI): TPromise<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user