1668
1669
public changeDecorations<T>(callback: (changeAccessor: model.IModelDecorationsChangeAccessor) => T, ownerId: number = 0): T | null {
1671
>
1672
>
try {
1673
>
this._onDidChangeDecorations.beginDeferredEmit();
1674
>
return this._changeDecorations(ownerId, callback);
1675
>
} finally {
1676
>
this._onDidChangeDecorations.endDeferredEmit();
1677
>
}
1678
>
}
1679
1680
private _changeDecorations<T>(ownerId: number, callback: (changeAccessor: model.IModelDecorationsChangeAccessor) => T): T | null {
1681
>
const changeAccessor: model.IModelDecorationsChangeAccessor = {
textModel.ts
1682
>
addDecoration: (range: IRange, options: model.IModelDecorationOptions): string => {
1683
return this._deltaDecorationsImpl(ownerId, [], [{ range: range, options: options }])[0];
1684
},
1685
>
changeDecoration: (id: string, newRange: IRange): void => {
textModel.ts
1686
this._changeDecorationImpl(ownerId, id, newRange);
1687
},
1688
>
changeDecorationOptions: (id: string, options: model.IModelDecorationOptions) => {
textModel.ts
1689
this._changeDecorationOptionsImpl(ownerId, id, _normalizeOptions(options));
1690
},
1691
>
removeDecoration: (id: string): void => {
textModel.ts
1692
this._deltaDecorationsImpl(ownerId, [id], []);
1693
},
1694
>
deltaDecorations: (oldDecorations: string[], newDecorations: model.IModelDeltaDecoration[]): string[] => {
textModel.ts
1695
if (oldDecorations.length === 0 && newDecorations.length === 0) {
1696
// nothing to do