nb decoration api first cut.

This commit is contained in:
rebornix
2020-09-16 14:00:07 -07:00
parent 50cc1d0e97
commit 289bce5e1a
16 changed files with 343 additions and 25 deletions

View File

@@ -99,6 +99,8 @@ export class ExtHostNotebookEditor extends Disposable implements vscode.Notebook
readonly onDidDispose: Event<void> = this._onDidDispose.event;
readonly onDidReceiveMessage: vscode.Event<any> = this._onDidReceiveMessage.event;
private _hasDecorationsForKey: { [key: string]: boolean; } = Object.create(null);
constructor(
readonly id: string,
private readonly _viewType: string,
@@ -214,6 +216,25 @@ export class ExtHostNotebookEditor extends Disposable implements vscode.Notebook
return this._proxy.$tryApplyEdits(this._viewType, this.document.uri, editData.documentVersionId, compressedEdits);
}
setDecorations(decorationType: vscode.NotebookEditorDecorationType, range: vscode.NotebookCellRange): void {
const willBeEmpty = (range.start === range.end);
if (willBeEmpty && !this._hasDecorationsForKey[decorationType.key]) {
// avoid no-op call to the renderer
return;
}
if (willBeEmpty) {
delete this._hasDecorationsForKey[decorationType.key];
} else {
this._hasDecorationsForKey[decorationType.key] = true;
}
return this._proxy.$trySetDecorations(
this.id,
range,
decorationType.key
);
}
revealRange(range: vscode.NotebookCellRange, revealType?: extHostTypes.NotebookEditorRevealType) {
this._proxy.$tryRevealRange(this.id, range, revealType || extHostTypes.NotebookEditorRevealType.Default);
}