hide proxy from TextEditorDecorationType

This commit is contained in:
Johannes Rieken 2021-02-01 17:06:51 +01:00
parent a0c75f6053
commit 2ceeaeb681
3 changed files with 11 additions and 11 deletions

View file

@ -20,7 +20,6 @@ suite('vscode', function () {
});
test('no rpc, createTextEditorDecorationType(...)', function () {
this.skip();
const item = vscode.window.createTextEditorDecorationType({});
dispo.push(item);
assertNoRpcFromEntry([item, 'TextEditorDecorationType']);

View file

@ -16,22 +16,23 @@ import type * as vscode from 'vscode';
import { ILogService } from 'vs/platform/log/common/log';
import { Lazy } from 'vs/base/common/lazy';
export class TextEditorDecorationType implements vscode.TextEditorDecorationType {
export class TextEditorDecorationType {
private static readonly _Keys = new IdGenerator('TextEditorDecorationType');
private _proxy: MainThreadTextEditorsShape;
public key: string;
readonly value: vscode.TextEditorDecorationType;
constructor(proxy: MainThreadTextEditorsShape, options: vscode.DecorationRenderOptions) {
this.key = TextEditorDecorationType._Keys.nextId();
this._proxy = proxy;
this._proxy.$registerTextEditorDecorationType(this.key, TypeConverters.DecorationRenderOptions.from(options));
const key = TextEditorDecorationType._Keys.nextId();
proxy.$registerTextEditorDecorationType(key, TypeConverters.DecorationRenderOptions.from(options));
this.value = Object.freeze({
key,
dispose() {
proxy.$removeTextEditorDecorationType(key);
}
});
}
public dispose(): void {
this._proxy.$removeTextEditorDecorationType(this.key);
}
}
export interface ITextEditOperation {

View file

@ -92,7 +92,7 @@ export class ExtHostEditors implements ExtHostEditorsShape {
}
createTextEditorDecorationType(options: vscode.DecorationRenderOptions): vscode.TextEditorDecorationType {
return new TextEditorDecorationType(this._proxy, options);
return new TextEditorDecorationType(this._proxy, options).value;
}
// --- called from main thread