Skip to content

Commit 8013a36

Browse files
authored
Fix nb diff overview ruler scaling. (microsoft#161832)
1 parent 741fa37 commit 8013a36

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,15 @@ export class NotebookDiffOverviewRuler extends Themable {
124124
private _layoutNow() {
125125
const layoutInfo = this.notebookEditor.getLayoutInfo();
126126
const height = layoutInfo.height;
127+
const scrollHeight = layoutInfo.scrollHeight;
127128
const ratio = browser.PixelRatio.value;
128129
this._domNode.setWidth(this.width);
129130
this._domNode.setHeight(height);
130131
this._domNode.domNode.width = this.width * ratio;
131132
this._domNode.domNode.height = height * ratio;
132133
const ctx = this._domNode.domNode.getContext('2d')!;
133134
ctx.clearRect(0, 0, this.width * ratio, height * ratio);
134-
this._renderCanvas(ctx, this.width * ratio, ratio);
135+
this._renderCanvas(ctx, this.width * ratio, height * ratio, scrollHeight * ratio, ratio);
135136
this._renderOverviewViewport();
136137
}
137138

@@ -168,7 +169,7 @@ export class NotebookDiffOverviewRuler extends Themable {
168169
};
169170
}
170171

171-
private _renderCanvas(ctx: CanvasRenderingContext2D, width: number, ratio: number) {
172+
private _renderCanvas(ctx: CanvasRenderingContext2D, width: number, height: number, scrollHeight: number, ratio: number) {
172173
if (!this._insertColorHex || !this._removeColorHex) {
173174
// no op when colors are not yet known
174175
return;
@@ -179,7 +180,8 @@ export class NotebookDiffOverviewRuler extends Themable {
179180
for (let i = 0; i < this._diffElementViewModels.length; i++) {
180181
const element = this._diffElementViewModels[i];
181182

182-
const cellHeight = element.layoutInfo.totalHeight * ratio;
183+
const cellHeight = (element.layoutInfo.totalHeight / scrollHeight) * ratio * height;
184+
183185
switch (element.type) {
184186
case 'insert':
185187
ctx.fillStyle = this._insertColorHex;

0 commit comments

Comments
 (0)