1489
public applyEdits(operations: readonly model.IIdentifiedSingleEditOperation[], computeUndoEdits: true, reason: TextModelEditSource): model.IValidEditOperation[];
1490
public applyEdits(rawOperations: readonly model.IIdentifiedSingleEditOperation[], computeUndoEdits?: boolean, reason?: TextModelEditSource): void | model.IValidEditOperation[] {
1492
>
this._onDidChangeDecorations.beginDeferredEmit();
1493
>
this._eventEmitter.beginDeferredEmit();
1494
>
const operations = this._validateEditOperations(rawOperations);
1495
>
1496
>
return this._doApplyEdits(operations, computeUndoEdits ?? false, reason ?? EditSources.applyEdits());
1497
>
} finally {
1498
>
this._eventEmitter.endDeferredEmit();
1499
>
this._onDidChangeDecorations.endDeferredEmit();
1500
>
}
1501
>
}
1502
1503
private _doApplyEdits(rawOperations: model.ValidAnnotatedEditOperation[], computeUndoEdits: boolean, reason: TextModelEditSource, resultingSelection: Selection[] | null = null): void | model.IValidEditOperation[] {
1505
>
const oldLineCount = this._buffer.getLineCount();
1506
>
const result = this._buffer.applyEdits(rawOperations, this._options.trimAutoWhitespace, computeUndoEdits);
1507
>
const newLineCount = this._buffer.getLineCount();
1508
>
1509
>
const contentChanges = result.changes;
1510
>
this._trimAutoWhitespaceLines = result.trimAutoWhitespaceLineNumbers;
1511
>
1512
>
if (contentChanges.length !== 0) {
1513
// We do a first pass to update decorations
1514
// because we want to read decorations in the second pass