only clear relevant part of canvas on marker dispose
This commit is contained in:
@@ -23,7 +23,7 @@ export class DecorationService extends Disposable implements IDecorationService
|
|||||||
private _animationFrame: number | undefined;
|
private _animationFrame: number | undefined;
|
||||||
|
|
||||||
private readonly _bufferDecorations: BufferDecoration[] = [];
|
private readonly _bufferDecorations: BufferDecoration[] = [];
|
||||||
private _scrollDecorations: ScrollbarDecoration[] = [];
|
private _scrollbarDecorations: ScrollbarDecoration[] = [];
|
||||||
|
|
||||||
private _scrollbarDecorationCanvas: CanvasRenderingContext2D | null = null;
|
private _scrollbarDecorationCanvas: CanvasRenderingContext2D | null = null;
|
||||||
private _scrollbarDecorationNode: HTMLCanvasElement | undefined;
|
private _scrollbarDecorationNode: HTMLCanvasElement | undefined;
|
||||||
@@ -60,10 +60,10 @@ export class DecorationService extends Disposable implements IDecorationService
|
|||||||
if (this._screenElement && this._container && this._screenElement.contains(this._container)) {
|
if (this._screenElement && this._container && this._screenElement.contains(this._container)) {
|
||||||
this._screenElement.removeChild(this._container);
|
this._screenElement.removeChild(this._container);
|
||||||
}
|
}
|
||||||
for (const scrollbarDecoration of this._scrollDecorations) {
|
for (const scrollbarDecoration of this._scrollbarDecorations) {
|
||||||
scrollbarDecoration.dispose();
|
scrollbarDecoration.dispose();
|
||||||
}
|
}
|
||||||
this._scrollDecorations = [];
|
this._scrollbarDecorations = [];
|
||||||
this._scrollbarDecorationNode?.remove();
|
this._scrollbarDecorationNode?.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,11 +86,11 @@ export class DecorationService extends Disposable implements IDecorationService
|
|||||||
if (!this._container) {
|
if (!this._container) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const bufferDecoration = this._instantiationService.createInstance(BufferDecoration, decorationOptions, this._container);
|
const decoration = this._instantiationService.createInstance(BufferDecoration, decorationOptions, this._container);
|
||||||
this._bufferDecorations.push(bufferDecoration);
|
this._bufferDecorations.push(decoration);
|
||||||
bufferDecoration.onDispose(() => this._bufferDecorations.splice(this._bufferDecorations.indexOf(bufferDecoration), 1));
|
decoration.onDispose(() => this._bufferDecorations.splice(this._bufferDecorations.indexOf(decoration), 1));
|
||||||
this._queueRefresh();
|
this._queueRefresh();
|
||||||
return bufferDecoration;
|
return decoration;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _registerScrollbarDecoration(marker: IMarker, color: string): IDecoration | undefined {
|
private _registerScrollbarDecoration(marker: IMarker, color: string): IDecoration | undefined {
|
||||||
@@ -101,17 +101,18 @@ export class DecorationService extends Disposable implements IDecorationService
|
|||||||
this._scrollbarDecorationCanvas = this._scrollbarDecorationNode.getContext('2d');
|
this._scrollbarDecorationCanvas = this._scrollbarDecorationNode.getContext('2d');
|
||||||
this._refreshScollbarDecorations();
|
this._refreshScollbarDecorations();
|
||||||
}
|
}
|
||||||
const scrollbarDecoration = new ScrollbarDecoration({ marker, scrollbarDecorationColor: color }, this._scrollbarDecorationNode, this._scrollbarDecorationCanvas!, this._bufferService);
|
const decoration = new ScrollbarDecoration({ marker, scrollbarDecorationColor: color }, this._scrollbarDecorationNode, this._scrollbarDecorationCanvas!, this._bufferService);
|
||||||
this._scrollDecorations.push(scrollbarDecoration);
|
decoration.onDispose(() => this._scrollbarDecorations.splice(this._scrollbarDecorations.indexOf(decoration), 1));
|
||||||
return scrollbarDecoration;
|
this._scrollbarDecorations.push(decoration);
|
||||||
|
return decoration;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _refreshBufferDecorations(shouldRecreate?: boolean): void {
|
private _refreshBufferDecorations(shouldRecreate?: boolean): void {
|
||||||
if (!this._renderService) {
|
if (!this._renderService) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const bufferDecoration of this._bufferDecorations) {
|
for (const decoration of this._bufferDecorations) {
|
||||||
bufferDecoration.render(this._renderService, shouldRecreate);
|
decoration.render(this._renderService, shouldRecreate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +125,7 @@ export class DecorationService extends Disposable implements IDecorationService
|
|||||||
this._scrollbarDecorationNode.width = Math.floor(ScrollbarConstants.WIDTH * window.devicePixelRatio);
|
this._scrollbarDecorationNode.width = Math.floor(ScrollbarConstants.WIDTH * window.devicePixelRatio);
|
||||||
this._scrollbarDecorationNode.height = Math.floor(this._viewportElement.clientHeight * window.devicePixelRatio);
|
this._scrollbarDecorationNode.height = Math.floor(this._viewportElement.clientHeight * window.devicePixelRatio);
|
||||||
this._scrollbarDecorationCanvas.clearRect(0, 0, this._scrollbarDecorationCanvas.canvas.width, this._scrollbarDecorationCanvas.canvas.height);
|
this._scrollbarDecorationCanvas.clearRect(0, 0, this._scrollbarDecorationCanvas.canvas.width, this._scrollbarDecorationCanvas.canvas.height);
|
||||||
for (const decoration of this._scrollDecorations) {
|
for (const decoration of this._scrollbarDecorations) {
|
||||||
decoration.render();
|
decoration.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,8 +173,17 @@ export class ScrollbarDecoration extends Disposable implements IDecoration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override dispose(): void {
|
public override dispose(): void {
|
||||||
this._ctx.clearRect(0, 0, this._ctx.canvas.width, this._ctx.canvas.height);
|
if (this._isDisposed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._ctx.clearRect(
|
||||||
|
0,
|
||||||
|
this.element.height * (this.marker.line / this._bufferService.buffers.active.lines.length),
|
||||||
|
this.element.width,
|
||||||
|
window.devicePixelRatio
|
||||||
|
);
|
||||||
|
this.isDisposed = true;
|
||||||
|
this._onDispose.fire();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user