From fbc1c189ffc7c2e30a4f1c9fb4757b542a99b550 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 21 Jan 2020 09:11:34 +0100 Subject: [PATCH 1/3] Bring back version check to avoid flickering caused by coordinates conversion --- .../src/features/semanticTokens.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/extensions/typescript-language-features/src/features/semanticTokens.ts b/extensions/typescript-language-features/src/features/semanticTokens.ts index fc6c770a971..3c3aff06202 100644 --- a/extensions/typescript-language-features/src/features/semanticTokens.ts +++ b/extensions/typescript-language-features/src/features/semanticTokens.ts @@ -68,11 +68,21 @@ class DocumentSemanticTokensProvider implements vscode.DocumentSemanticTokensPro return null; } + const versionBeforeRequest = document.version; + const response = await (this.client as ExperimentalProtocol.IExtendedTypeScriptServiceClient).execute('encodedSemanticClassifications-full', requestArg, token); if (response.type !== 'response' || !response.body) { return null; } + const versionAfterRequest = document.version; + + if (versionBeforeRequest !== versionAfterRequest) { + // cannot convert result's offsets to (line;col) values correctly + // a new request will come in soon... + return null; + } + const tokenSpan = response.body.spans; const builder = new vscode.SemanticTokensBuilder(); From 40383523c4ed744750c50f3213decc87545b1112 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 21 Jan 2020 09:19:14 +0100 Subject: [PATCH 2/3] Fixes #85531: Support overviewRulerLanes = 0 --- src/vs/base/browser/fastDomNode.ts | 10 ++++++++++ .../overviewRuler/decorationsOverviewRuler.ts | 15 +++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/vs/base/browser/fastDomNode.ts b/src/vs/base/browser/fastDomNode.ts index 5c688bd3496..12886f27e79 100644 --- a/src/vs/base/browser/fastDomNode.ts +++ b/src/vs/base/browser/fastDomNode.ts @@ -25,6 +25,7 @@ export class FastDomNode { private _display: string; private _position: string; private _visibility: string; + private _backgroundColor: string; private _layerHint: boolean; private _contain: 'none' | 'strict' | 'content' | 'size' | 'layout' | 'style' | 'paint'; @@ -47,6 +48,7 @@ export class FastDomNode { this._display = ''; this._position = ''; this._visibility = ''; + this._backgroundColor = ''; this._layerHint = false; this._contain = 'none'; } @@ -200,6 +202,14 @@ export class FastDomNode { this.domNode.style.visibility = this._visibility; } + public setBackgroundColor(backgroundColor: string): void { + if (this._backgroundColor === backgroundColor) { + return; + } + this._backgroundColor = backgroundColor; + this.domNode.style.backgroundColor = this._backgroundColor; + } + public setLayerHinting(layerHint: boolean): void { if (this._layerHint === layerHint) { return; diff --git a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts index 687b9985268..3e57c3f2f94 100644 --- a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts +++ b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts @@ -74,8 +74,14 @@ class Settings { this.right = position.right; this.domWidth = position.width; this.domHeight = position.height; - this.canvasWidth = (this.domWidth * this.pixelRatio) | 0; - this.canvasHeight = (this.domHeight * this.pixelRatio) | 0; + if (this.overviewRulerLanes === 0) { + // overview ruler is off + this.canvasWidth = 0; + this.canvasHeight = 0; + } else { + this.canvasWidth = (this.domWidth * this.pixelRatio) | 0; + this.canvasHeight = (this.domHeight * this.pixelRatio) | 0; + } const [x, w] = this._initLanes(1, this.canvasWidth, this.overviewRulerLanes); this.x = x; @@ -303,6 +309,11 @@ export class DecorationsOverviewRuler extends ViewPart { } private _render(): void { + if (this._settings.overviewRulerLanes === 0) { + // overview ruler is off + this._domNode.setBackgroundColor(this._settings.backgroundColor ? this._settings.backgroundColor : ''); + return; + } const canvasWidth = this._settings.canvasWidth; const canvasHeight = this._settings.canvasHeight; const lineHeight = this._settings.lineHeight; From 6a2268596bc2c2e74c650a52ae8251197b73e520 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 21 Jan 2020 09:30:59 +0100 Subject: [PATCH 3/3] Fixes #85532: Have the minimap use 0 for the canvas width or height, and avoid hitting #28990 again --- .../browser/viewParts/minimap/minimap.ts | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index 7a248a3135c..55945f681e9 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -126,8 +126,8 @@ class MinimapOptions { this.minimapWidth = layoutInfo.minimapWidth; this.minimapHeight = layoutInfo.height; - this.canvasInnerWidth = Math.max(1, Math.floor(pixelRatio * this.minimapWidth)); - this.canvasInnerHeight = Math.max(1, Math.floor(pixelRatio * this.minimapHeight)); + this.canvasInnerWidth = Math.floor(pixelRatio * this.minimapWidth); + this.canvasInnerHeight = Math.floor(pixelRatio * this.minimapHeight); this.canvasOuterWidth = this.canvasInnerWidth / pixelRatio; this.canvasOuterHeight = this.canvasInnerHeight / pixelRatio; @@ -657,16 +657,18 @@ export class Minimap extends ViewPart { this._slider.setWidth(this._options.minimapWidth); } - private _getBuffer(): ImageData { + private _getBuffer(): ImageData | null { if (!this._buffers) { - this._buffers = new MinimapBuffers( - this._canvas.domNode.getContext('2d')!, - this._options.canvasInnerWidth, - this._options.canvasInnerHeight, - this._tokensColorTracker.getColor(ColorId.DefaultBackground) - ); + if (this._options.canvasInnerWidth > 0 && this._options.canvasInnerHeight > 0) { + this._buffers = new MinimapBuffers( + this._canvas.domNode.getContext('2d')!, + this._options.canvasInnerWidth, + this._options.canvasInnerHeight, + this._tokensColorTracker.getColor(ColorId.DefaultBackground) + ); + } } - return this._buffers!.getBuffer(); + return this._buffers ? this._buffers.getBuffer() : null; } private _onOptionsMaybeChanged(): boolean { @@ -906,7 +908,7 @@ export class Minimap extends ViewPart { canvasContext.fillRect(x, y, width, height); } - private renderLines(layout: MinimapLayout): RenderData { + private renderLines(layout: MinimapLayout): RenderData | null { const renderMinimap = this._options.renderMinimap; const charRenderer = this._options.charRenderer(); const startLineNumber = layout.startLineNumber; @@ -923,6 +925,10 @@ export class Minimap extends ViewPart { // Oh well!! We need to repaint some lines... const imageData = this._getBuffer(); + if (!imageData) { + // 0 width or 0 height canvas, nothing to do + return null; + } // Render untouched lines by using last rendered data. let [_dirtyY1, _dirtyY2, needed] = Minimap._renderUntouchedLines(