From 7a652c4169b1865962c988deaee20111f5cf55bf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 27 May 2022 11:56:54 -0700 Subject: [PATCH] Allow up to double the size for overview ruler decorations Fixes #3840 --- .../decorations/OverviewRulerRenderer.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/browser/decorations/OverviewRulerRenderer.ts b/src/browser/decorations/OverviewRulerRenderer.ts index f31409cab3..22f3ddf5c5 100644 --- a/src/browser/decorations/OverviewRulerRenderer.ts +++ b/src/browser/decorations/OverviewRulerRenderer.ts @@ -88,6 +88,7 @@ export class OverviewRulerRenderer extends Disposable { })); this.register(this._bufferService.onScroll(() => { if (this._lastKnownBufferLength !== this._bufferService.buffers.normal.lines.length) { + this._refreshDrawHeightConstants(); this._refreshColorZonePadding(); } })); @@ -132,10 +133,7 @@ export class OverviewRulerRenderer extends Disposable { drawWidth.center = innerWidth; drawWidth.right = outerWidth; // height - drawHeight.full = Math.round(2 * window.devicePixelRatio); - drawHeight.left = Math.round(6 * window.devicePixelRatio); - drawHeight.center = Math.round(6 * window.devicePixelRatio); - drawHeight.right = Math.round(6 * window.devicePixelRatio); + this._refreshDrawHeightConstants(); // x drawX.full = 0; drawX.left = 0; @@ -143,6 +141,17 @@ export class OverviewRulerRenderer extends Disposable { drawX.right = drawWidth.left + drawWidth.center; } + private _refreshDrawHeightConstants(): void { + drawHeight.full = Math.round(2 * window.devicePixelRatio); + // Calculate actual pixels per line + const pixelsPerLine = this._canvas.height / this._bufferService.buffer.lines.length; + // Clamp actual pixels within a range + const nonFullHeight = Math.round(Math.max(Math.min(pixelsPerLine, 12), 6) * window.devicePixelRatio); + drawHeight.left = nonFullHeight; + drawHeight.center = nonFullHeight; + drawHeight.right = nonFullHeight; + } + private _refreshColorZonePadding(): void { this._colorZoneStore.setPadding({ full: Math.floor(this._bufferService.buffers.active.lines.length / (this._canvas.height - 1) * drawHeight.full),