Skip to content

Commit 548becb

Browse files
committed
Merge remote-tracking branch 'origin/master' into pine/alwaysShowInlineDetails
2 parents 495effc + 6a22685 commit 548becb

4 files changed

Lines changed: 50 additions & 13 deletions

File tree

extensions/typescript-language-features/src/features/semanticTokens.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,21 @@ class DocumentSemanticTokensProvider implements vscode.DocumentSemanticTokensPro
6868
return null;
6969
}
7070

71+
const versionBeforeRequest = document.version;
72+
7173
const response = await (this.client as ExperimentalProtocol.IExtendedTypeScriptServiceClient).execute('encodedSemanticClassifications-full', requestArg, token);
7274
if (response.type !== 'response' || !response.body) {
7375
return null;
7476
}
7577

78+
const versionAfterRequest = document.version;
79+
80+
if (versionBeforeRequest !== versionAfterRequest) {
81+
// cannot convert result's offsets to (line;col) values correctly
82+
// a new request will come in soon...
83+
return null;
84+
}
85+
7686
const tokenSpan = response.body.spans;
7787

7888
const builder = new vscode.SemanticTokensBuilder();

src/vs/base/browser/fastDomNode.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class FastDomNode<T extends HTMLElement> {
2525
private _display: string;
2626
private _position: string;
2727
private _visibility: string;
28+
private _backgroundColor: string;
2829
private _layerHint: boolean;
2930
private _contain: 'none' | 'strict' | 'content' | 'size' | 'layout' | 'style' | 'paint';
3031

@@ -47,6 +48,7 @@ export class FastDomNode<T extends HTMLElement> {
4748
this._display = '';
4849
this._position = '';
4950
this._visibility = '';
51+
this._backgroundColor = '';
5052
this._layerHint = false;
5153
this._contain = 'none';
5254
}
@@ -200,6 +202,14 @@ export class FastDomNode<T extends HTMLElement> {
200202
this.domNode.style.visibility = this._visibility;
201203
}
202204

205+
public setBackgroundColor(backgroundColor: string): void {
206+
if (this._backgroundColor === backgroundColor) {
207+
return;
208+
}
209+
this._backgroundColor = backgroundColor;
210+
this.domNode.style.backgroundColor = this._backgroundColor;
211+
}
212+
203213
public setLayerHinting(layerHint: boolean): void {
204214
if (this._layerHint === layerHint) {
205215
return;

src/vs/editor/browser/viewParts/minimap/minimap.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ class MinimapOptions {
126126
this.minimapWidth = layoutInfo.minimapWidth;
127127
this.minimapHeight = layoutInfo.height;
128128

129-
this.canvasInnerWidth = Math.max(1, Math.floor(pixelRatio * this.minimapWidth));
130-
this.canvasInnerHeight = Math.max(1, Math.floor(pixelRatio * this.minimapHeight));
129+
this.canvasInnerWidth = Math.floor(pixelRatio * this.minimapWidth);
130+
this.canvasInnerHeight = Math.floor(pixelRatio * this.minimapHeight);
131131

132132
this.canvasOuterWidth = this.canvasInnerWidth / pixelRatio;
133133
this.canvasOuterHeight = this.canvasInnerHeight / pixelRatio;
@@ -657,16 +657,18 @@ export class Minimap extends ViewPart {
657657
this._slider.setWidth(this._options.minimapWidth);
658658
}
659659

660-
private _getBuffer(): ImageData {
660+
private _getBuffer(): ImageData | null {
661661
if (!this._buffers) {
662-
this._buffers = new MinimapBuffers(
663-
this._canvas.domNode.getContext('2d')!,
664-
this._options.canvasInnerWidth,
665-
this._options.canvasInnerHeight,
666-
this._tokensColorTracker.getColor(ColorId.DefaultBackground)
667-
);
662+
if (this._options.canvasInnerWidth > 0 && this._options.canvasInnerHeight > 0) {
663+
this._buffers = new MinimapBuffers(
664+
this._canvas.domNode.getContext('2d')!,
665+
this._options.canvasInnerWidth,
666+
this._options.canvasInnerHeight,
667+
this._tokensColorTracker.getColor(ColorId.DefaultBackground)
668+
);
669+
}
668670
}
669-
return this._buffers!.getBuffer();
671+
return this._buffers ? this._buffers.getBuffer() : null;
670672
}
671673

672674
private _onOptionsMaybeChanged(): boolean {
@@ -906,7 +908,7 @@ export class Minimap extends ViewPart {
906908
canvasContext.fillRect(x, y, width, height);
907909
}
908910

909-
private renderLines(layout: MinimapLayout): RenderData {
911+
private renderLines(layout: MinimapLayout): RenderData | null {
910912
const renderMinimap = this._options.renderMinimap;
911913
const charRenderer = this._options.charRenderer();
912914
const startLineNumber = layout.startLineNumber;
@@ -923,6 +925,10 @@ export class Minimap extends ViewPart {
923925
// Oh well!! We need to repaint some lines...
924926

925927
const imageData = this._getBuffer();
928+
if (!imageData) {
929+
// 0 width or 0 height canvas, nothing to do
930+
return null;
931+
}
926932

927933
// Render untouched lines by using last rendered data.
928934
let [_dirtyY1, _dirtyY2, needed] = Minimap._renderUntouchedLines(

src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ class Settings {
7474
this.right = position.right;
7575
this.domWidth = position.width;
7676
this.domHeight = position.height;
77-
this.canvasWidth = (this.domWidth * this.pixelRatio) | 0;
78-
this.canvasHeight = (this.domHeight * this.pixelRatio) | 0;
77+
if (this.overviewRulerLanes === 0) {
78+
// overview ruler is off
79+
this.canvasWidth = 0;
80+
this.canvasHeight = 0;
81+
} else {
82+
this.canvasWidth = (this.domWidth * this.pixelRatio) | 0;
83+
this.canvasHeight = (this.domHeight * this.pixelRatio) | 0;
84+
}
7985

8086
const [x, w] = this._initLanes(1, this.canvasWidth, this.overviewRulerLanes);
8187
this.x = x;
@@ -303,6 +309,11 @@ export class DecorationsOverviewRuler extends ViewPart {
303309
}
304310

305311
private _render(): void {
312+
if (this._settings.overviewRulerLanes === 0) {
313+
// overview ruler is off
314+
this._domNode.setBackgroundColor(this._settings.backgroundColor ? this._settings.backgroundColor : '');
315+
return;
316+
}
306317
const canvasWidth = this._settings.canvasWidth;
307318
const canvasHeight = this._settings.canvasHeight;
308319
const lineHeight = this._settings.lineHeight;

0 commit comments

Comments
 (0)