From 5059ea34850b91b21bc34604213c236b73578c8e Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 2 Jan 2021 08:38:08 -0600 Subject: [PATCH 01/10] fix: inline redrawRangesOnLayer in updateTokensLayer --- lib/mixins/canvas-drawer.js | 39 ++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index eb36f528..e0812bcc 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -154,7 +154,44 @@ export default class CanvasDrawer extends Mixin { updateTokensLayer (firstRow, lastRow) { const intactRanges = computeIntactRanges(firstRow, lastRow, this.pendingChanges, this.offscreenFirstRow, this.offscreenLastRow) - this.redrawRangesOnLayer(this.tokensLayer, intactRanges, firstRow, lastRow, this.drawLines) + // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately. + + // redrawRangesOnLayer inlined (this.redrawRangesOnLayer(this.tokensLayer, intactRanges, firstRow, lastRow, this.drawLines)) + const layer = this.tokensLayer + + const devicePixelRatio = this.minimap.getDevicePixelRatio() + const lineHeight = this.minimap.getLineHeight() * devicePixelRatio + + layer.clearCanvas() + + if (intactRanges.length === 0) { + this.drawLines(firstRow, lastRow, 0) + } else { + for (let j = 0, len = intactRanges.length; j < len; j++) { + const intact = intactRanges[j] + + layer.copyPartFromOffscreen( + intact.offscreenRow * lineHeight, + (intact.start - firstRow) * lineHeight, + (intact.end - intact.start) * lineHeight + ) + } + // drawLinesForRanges inlined + let currentRow = firstRow + for (let i = 0, len = intactRanges.length; i < len; i++) { + const range = intactRanges[i] + + this.drawLines(currentRow, range.start, currentRow - firstRow) + + currentRow = range.end + } + if (currentRow <= lastRow) { + this.drawLines(currentRow, lastRow, currentRow - firstRow) + } + } + + layer.resetOffscreenSize() + layer.copyToOffscreen() } /** From 436f4b77ee6cf4a94867cf67270be64bb7d67355 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 2 Jan 2021 08:56:46 -0600 Subject: [PATCH 02/10] fix: refactor the parameters of drawLines out of loop --- lib/mixins/canvas-drawer.js | 53 ++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index e0812bcc..f455daa8 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -157,20 +157,28 @@ export default class CanvasDrawer extends Mixin { // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately. // redrawRangesOnLayer inlined (this.redrawRangesOnLayer(this.tokensLayer, intactRanges, firstRow, lastRow, this.drawLines)) - const layer = this.tokensLayer const devicePixelRatio = this.minimap.getDevicePixelRatio() const lineHeight = this.minimap.getLineHeight() * devicePixelRatio + const charHeight = this.minimap.getCharHeight() * devicePixelRatio + const charWidth = this.minimap.getCharWidth() * devicePixelRatio + const canvasWidth = this.tokensLayer.getSize().width + const context = this.tokensLayer.context + const editor = this.minimap.getTextEditor() + const editorElement = this.minimap.getTextEditorElement() + const displayCodeHighlights = this.displayCodeHighlights + const ignoreWhitespacesInTokens = this.ignoreWhitespacesInTokens + const maxTokensInOneLine = this.maxTokensInOneLine - layer.clearCanvas() + this.tokensLayer.clearCanvas() if (intactRanges.length === 0) { - this.drawLines(firstRow, lastRow, 0) + this.drawLines(firstRow, lastRow, 0, lineHeight, charHeight, charWidth, canvasWidth, context, editor, editorElement, displayCodeHighlights, ignoreWhitespacesInTokens, maxTokensInOneLine) } else { for (let j = 0, len = intactRanges.length; j < len; j++) { const intact = intactRanges[j] - layer.copyPartFromOffscreen( + this.tokensLayer.copyPartFromOffscreen( intact.offscreenRow * lineHeight, (intact.start - firstRow) * lineHeight, (intact.end - intact.start) * lineHeight @@ -181,17 +189,17 @@ export default class CanvasDrawer extends Mixin { for (let i = 0, len = intactRanges.length; i < len; i++) { const range = intactRanges[i] - this.drawLines(currentRow, range.start, currentRow - firstRow) + this.drawLines(currentRow, range.start, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, context, editor, editorElement, displayCodeHighlights, ignoreWhitespacesInTokens, maxTokensInOneLine) currentRow = range.end } if (currentRow <= lastRow) { - this.drawLines(currentRow, lastRow, currentRow - firstRow) + this.drawLines(currentRow, lastRow, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, context, editor, editorElement, displayCodeHighlights, ignoreWhitespacesInTokens, maxTokensInOneLine) } } - layer.resetOffscreenSize() - layer.copyToOffscreen() + this.tokensLayer.resetOffscreenSize() + this.tokensLayer.copyToOffscreen() } /** @@ -459,25 +467,26 @@ export default class CanvasDrawer extends Mixin { * @param {number} lastRow the last row to render * @param {number} offsetRow the relative offset to apply to rows when * rendering them + * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio + * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio + * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio + * @param {number} canvasWidth this.tokensLayer.getSize().width + * @param {CanvasRenderingContext2D} context this.tokensLayer.context + * @param {TextEditor} editor this.minimap.getTextEditor() + * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() + * @param {boolean} displayCodeHighlights this.displayCodeHighlights + * @param {boolean} ignoreWhitespacesInTokens this.ignoreWhitespacesInTokens + * @param {number} maxTokensInOneLine this.maxTokensInOneLine * @access private */ - drawLines (firstRow, lastRow, offsetRow) { - if (firstRow > lastRow) { return } - - const devicePixelRatio = this.minimap.getDevicePixelRatio() - const lineHeight = this.minimap.getLineHeight() * devicePixelRatio - const charHeight = this.minimap.getCharHeight() * devicePixelRatio - const charWidth = this.minimap.getCharWidth() * devicePixelRatio - const displayCodeHighlights = this.displayCodeHighlights - const context = this.tokensLayer.context - const { width: canvasWidth } = this.tokensLayer.getSize() + drawLines (firstRow, lastRow, offsetRow, lineHeight, charHeight, charWidth, canvasWidth, context, editor, editorElement, displayCodeHighlights, ignoreWhitespacesInTokens, maxTokensInOneLine) { + // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately. - const editor = this.minimap.getTextEditor() - const editorElement = this.minimap.getTextEditorElement() + if (firstRow > lastRow) { return } let lastLine, x let y = (offsetRow * lineHeight) - lineHeight - eachTokenForScreenRows(firstRow, lastRow, editor, this.maxTokensInOneLine, (line, token) => { + eachTokenForScreenRows(firstRow, lastRow, editor, maxTokensInOneLine, (line, token) => { if (lastLine !== line) { x = 0 y += lineHeight @@ -494,7 +503,7 @@ export default class CanvasDrawer extends Mixin { : this.getDefaultColor(editorElement) x = drawToken( - context, token.text, color, x, y, charWidth, charHeight, this.ignoreWhitespacesInTokens + context, token.text, color, x, y, charWidth, charHeight, ignoreWhitespacesInTokens ) } }) From bffd277ee15a3697b81227dfdef6ee69f0287a06 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 2 Jan 2021 10:09:10 -0600 Subject: [PATCH 03/10] fix: move the consts out of updateTokensLayer So it can be shared by other update functions --- lib/mixins/canvas-drawer.js | 39 ++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index f455daa8..1e6eadd3 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -122,7 +122,19 @@ export default class CanvasDrawer extends Mixin { const firstRow = this.minimap.getFirstVisibleScreenRow() const lastRow = this.minimap.getLastVisibleScreenRow() - this.updateTokensLayer(firstRow, lastRow) + const devicePixelRatio = this.minimap.getDevicePixelRatio() + const lineHeight = this.minimap.getLineHeight() * devicePixelRatio + const charHeight = this.minimap.getCharHeight() * devicePixelRatio + const charWidth = this.minimap.getCharWidth() * devicePixelRatio + const canvasWidth = this.tokensLayer.getSize().width + const context = this.tokensLayer.context + const editor = this.minimap.getTextEditor() + const editorElement = this.minimap.getTextEditorElement() + const displayCodeHighlights = this.displayCodeHighlights + const ignoreWhitespacesInTokens = this.ignoreWhitespacesInTokens + const maxTokensInOneLine = this.maxTokensInOneLine + + this.updateTokensLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, context, editor, editorElement, displayCodeHighlights, ignoreWhitespacesInTokens, maxTokensInOneLine) this.updateBackDecorationsLayer(firstRow, lastRow) this.updateFrontDecorationsLayer(firstRow, lastRow) @@ -149,27 +161,26 @@ export default class CanvasDrawer extends Mixin { * * @param {number} firstRow firstRow the first row of the range to update * @param {number} lastRow lastRow the last row of the range to update + + * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio + * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio + * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio + * @param {number} canvasWidth this.tokensLayer.getSize().width + * @param {CanvasRenderingContext2D} context this.tokensLayer.context + * @param {TextEditor} editor this.minimap.getTextEditor() + * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() + * @param {boolean} displayCodeHighlights this.displayCodeHighlights + * @param {boolean} ignoreWhitespacesInTokens this.ignoreWhitespacesInTokens + * @param {number} maxTokensInOneLine this.maxTokensInOneLine * @access private */ - updateTokensLayer (firstRow, lastRow) { + updateTokensLayer (firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, context, editor, editorElement, displayCodeHighlights, ignoreWhitespacesInTokens, maxTokensInOneLine) { const intactRanges = computeIntactRanges(firstRow, lastRow, this.pendingChanges, this.offscreenFirstRow, this.offscreenLastRow) // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately. // redrawRangesOnLayer inlined (this.redrawRangesOnLayer(this.tokensLayer, intactRanges, firstRow, lastRow, this.drawLines)) - const devicePixelRatio = this.minimap.getDevicePixelRatio() - const lineHeight = this.minimap.getLineHeight() * devicePixelRatio - const charHeight = this.minimap.getCharHeight() * devicePixelRatio - const charWidth = this.minimap.getCharWidth() * devicePixelRatio - const canvasWidth = this.tokensLayer.getSize().width - const context = this.tokensLayer.context - const editor = this.minimap.getTextEditor() - const editorElement = this.minimap.getTextEditorElement() - const displayCodeHighlights = this.displayCodeHighlights - const ignoreWhitespacesInTokens = this.ignoreWhitespacesInTokens - const maxTokensInOneLine = this.maxTokensInOneLine - this.tokensLayer.clearCanvas() if (intactRanges.length === 0) { From a05bca0d577ebc69488df0027e012f8f91529443 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 2 Jan 2021 10:14:49 -0600 Subject: [PATCH 04/10] fix: inline updateBackDecorationsLayer --- lib/mixins/canvas-drawer.js | 65 ++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 1e6eadd3..6d1f007d 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -135,8 +135,8 @@ export default class CanvasDrawer extends Mixin { const maxTokensInOneLine = this.maxTokensInOneLine this.updateTokensLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, context, editor, editorElement, displayCodeHighlights, ignoreWhitespacesInTokens, maxTokensInOneLine) - this.updateBackDecorationsLayer(firstRow, lastRow) - this.updateFrontDecorationsLayer(firstRow, lastRow) + this.updateBackDecorationsLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + this.updateFrontDecorationsLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) this.pendingChanges = [] this.pendingBackDecorationChanges = [] @@ -161,7 +161,7 @@ export default class CanvasDrawer extends Mixin { * * @param {number} firstRow firstRow the first row of the range to update * @param {number} lastRow lastRow the last row of the range to update - + * * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio @@ -219,12 +219,52 @@ export default class CanvasDrawer extends Mixin { * * @param {number} firstRow firstRow the first row of the range to update * @param {number} lastRow lastRow the last row of the range to update + * + * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio + * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio + * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio + * @param {number} canvasWidth this.tokensLayer.getSize().width + * @param {number} canvasHeight this.tokensLayer.getSize().height + * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() * @access private */ - updateBackDecorationsLayer (firstRow, lastRow) { + updateBackDecorationsLayer (firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) { const intactRanges = computeIntactRanges(firstRow, lastRow, this.pendingBackDecorationChanges, this.offscreenFirstRow, this.offscreenLastRow) - this.redrawRangesOnLayer(this.backLayer, intactRanges, firstRow, lastRow, this.drawBackDecorationsForLines) + // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately. + + // redrawRangesOnLayer inlined (this.redrawRangesOnLayer(this.backLayer, intactRanges, firstRow, lastRow, this.drawBackDecorationsForLines) + + this.backLayer.clearCanvas() + + if (intactRanges.length === 0) { + this.drawBackDecorationsForLines(firstRow, lastRow, 0, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + } else { + for (let j = 0, len = intactRanges.length; j < len; j++) { + const intact = intactRanges[j] + + this.backLayer.copyPartFromOffscreen( + intact.offscreenRow * lineHeight, + (intact.start - firstRow) * lineHeight, + (intact.end - intact.start) * lineHeight + ) + } + // drawLinesForRanges inlined + let currentRow = firstRow + for (let i = 0, len = intactRanges.length; i < len; i++) { + const range = intactRanges[i] + + this.drawBackDecorationsForLines(currentRow, range.start, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + + currentRow = range.end + } + if (currentRow <= lastRow) { + this.drawBackDecorationsForLines(currentRow, lastRow, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + } + } + + this.backLayer.resetOffscreenSize() + this.backLayer.copyToOffscreen() } /** @@ -385,17 +425,19 @@ export default class CanvasDrawer extends Mixin { * @param {number} lastRow the last row to render * @param {number} offsetRow the relative offset to apply to rows when * rendering them + * + * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio + * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio + * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio + * @param {number} canvasWidth this.tokensLayer.getSize().width + * @param {number} canvasHeight this.tokensLayer.getSize().height + * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() * @access private */ - drawBackDecorationsForLines (firstRow, lastRow, offsetRow) { + drawBackDecorationsForLines (firstRow, lastRow, offsetRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) { if (firstRow > lastRow) { return } - const devicePixelRatio = this.minimap.getDevicePixelRatio() - const lineHeight = this.minimap.getLineHeight() * devicePixelRatio - const charHeight = this.minimap.getCharHeight() * devicePixelRatio - const charWidth = this.minimap.getCharWidth() * devicePixelRatio const decorations = this.minimap.decorationsByTypeThenRows(firstRow, lastRow) - const { width: canvasWidth, height: canvasHeight } = this.tokensLayer.getSize() const renderData = { context: this.backLayer.context, canvasWidth, @@ -405,7 +447,6 @@ export default class CanvasDrawer extends Mixin { charHeight, orders: Main.getPluginsOrder() } - const editorElement = this.minimap.getTextEditorElement() const drawCustomDecorationLambda = (decoration, data, decorationColor) => drawCustomDecoration(decoration, data, decorationColor, editorElement) backgroundDecorationDispatcher['background-custom'] = drawCustomDecorationLambda From dacf5465c99df96ebe61dd8b5dee86bb80688f62 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 2 Jan 2021 10:15:01 -0600 Subject: [PATCH 05/10] fix: inline updateFrontDecorationsLayer --- lib/mixins/canvas-drawer.js | 62 ++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 6d1f007d..dd7f65c4 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -126,7 +126,7 @@ export default class CanvasDrawer extends Mixin { const lineHeight = this.minimap.getLineHeight() * devicePixelRatio const charHeight = this.minimap.getCharHeight() * devicePixelRatio const charWidth = this.minimap.getCharWidth() * devicePixelRatio - const canvasWidth = this.tokensLayer.getSize().width + const { width: canvasWidth, height: canvasHeight } = this.tokensLayer.getSize() const context = this.tokensLayer.context const editor = this.minimap.getTextEditor() const editorElement = this.minimap.getTextEditorElement() @@ -273,12 +273,52 @@ export default class CanvasDrawer extends Mixin { * * @param {number} firstRow firstRow the first row of the range to update * @param {number} lastRow lastRow the last row of the range to update + * + * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio + * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio + * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio + * @param {number} canvasWidth this.tokensLayer.getSize().width + * @param {number} canvasHeight this.tokensLayer.getSize().height + * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() * @access private */ - updateFrontDecorationsLayer (firstRow, lastRow) { + updateFrontDecorationsLayer (firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) { const intactRanges = computeIntactRanges(firstRow, lastRow, this.pendingFrontDecorationChanges, this.offscreenFirstRow, this.offscreenLastRow) - this.redrawRangesOnLayer(this.frontLayer, intactRanges, firstRow, lastRow, this.drawFrontDecorationsForLines) + // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately. + + // redrawRangesOnLayer inlined (this.frontLayer(this.frontLayer, intactRanges, firstRow, lastRow, this.drawFrontDecorationsForLines) + + this.frontLayer.clearCanvas() + + if (intactRanges.length === 0) { + this.drawFrontDecorationsForLines(firstRow, lastRow, 0, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + } else { + for (let j = 0, len = intactRanges.length; j < len; j++) { + const intact = intactRanges[j] + + this.frontLayer.copyPartFromOffscreen( + intact.offscreenRow * lineHeight, + (intact.start - firstRow) * lineHeight, + (intact.end - intact.start) * lineHeight + ) + } + // drawLinesForRanges inlined + let currentRow = firstRow + for (let i = 0, len = intactRanges.length; i < len; i++) { + const range = intactRanges[i] + + this.drawFrontDecorationsForLines(currentRow, range.start, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + + currentRow = range.end + } + if (currentRow <= lastRow) { + this.drawFrontDecorationsForLines(currentRow, lastRow, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + } + } + + this.frontLayer.resetOffscreenSize() + this.frontLayer.copyToOffscreen() } // ###### ####### ## ####### ######## ###### @@ -472,17 +512,19 @@ export default class CanvasDrawer extends Mixin { * @param {number} lastRow the last row to render * @param {number} offsetRow the relative offset to apply to rows when * rendering them + * + * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio + * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio + * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio + * @param {number} canvasWidth this.tokensLayer.getSize().width + * @param {number} canvasHeight this.tokensLayer.getSize().height + * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() * @access private */ - drawFrontDecorationsForLines (firstRow, lastRow, offsetRow) { + drawFrontDecorationsForLines (firstRow, lastRow, offsetRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) { if (firstRow > lastRow) { return } - const devicePixelRatio = this.minimap.getDevicePixelRatio() - const lineHeight = this.minimap.getLineHeight() * devicePixelRatio - const charHeight = this.minimap.getCharHeight() * devicePixelRatio - const charWidth = this.minimap.getCharWidth() * devicePixelRatio const decorations = this.minimap.decorationsByTypeThenRows(firstRow, lastRow) - const { width: canvasWidth, height: canvasHeight } = this.tokensLayer.getSize() const renderData = { context: this.frontLayer.context, canvasWidth, @@ -493,8 +535,6 @@ export default class CanvasDrawer extends Mixin { orders: Main.getPluginsOrder() } - const editorElement = this.minimap.getTextEditorElement() - const drawCustomDecorationLambda = (decoration, data, decorationColor) => drawCustomDecoration(decoration, data, decorationColor, editorElement) frontDecorationDispatcher['foreground-custom'] = drawCustomDecorationLambda From 1396a49de7b862cc4d4c10d7f32bf8e4c9b83373 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 2 Jan 2021 10:18:01 -0600 Subject: [PATCH 06/10] fix: comment out unused functions --- lib/mixins/canvas-drawer.js | 76 +++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index dd7f65c4..af20d6be 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -405,31 +405,32 @@ export default class CanvasDrawer extends Mixin { * @param {number} lastRow lastRow the last row of the range to update * @param {Function} method the render method to use for the lines drawing * @access private + * Unused (inlined the code for performance reasons) */ - redrawRangesOnLayer (layer, intactRanges, firstRow, lastRow, method) { - const devicePixelRatio = this.minimap.getDevicePixelRatio() - const lineHeight = this.minimap.getLineHeight() * devicePixelRatio - - layer.clearCanvas() - - if (intactRanges.length === 0) { - method.call(this, firstRow, lastRow, 0) - } else { - for (let j = 0, len = intactRanges.length; j < len; j++) { - const intact = intactRanges[j] - - layer.copyPartFromOffscreen( - intact.offscreenRow * lineHeight, - (intact.start - firstRow) * lineHeight, - (intact.end - intact.start) * lineHeight - ) - } - this.drawLinesForRanges(method, intactRanges, firstRow, lastRow) - } - - layer.resetOffscreenSize() - layer.copyToOffscreen() - } + // redrawRangesOnLayer (layer, intactRanges, firstRow, lastRow, method) { + // const devicePixelRatio = this.minimap.getDevicePixelRatio() + // const lineHeight = this.minimap.getLineHeight() * devicePixelRatio + // + // layer.clearCanvas() + // + // if (intactRanges.length === 0) { + // method.call(this, firstRow, lastRow, 0) + // } else { + // for (let j = 0, len = intactRanges.length; j < len; j++) { + // const intact = intactRanges[j] + // + // layer.copyPartFromOffscreen( + // intact.offscreenRow * lineHeight, + // (intact.start - firstRow) * lineHeight, + // (intact.end - intact.start) * lineHeight + // ) + // } + // this.drawLinesForRanges(method, intactRanges, firstRow, lastRow) + // } + // + // layer.resetOffscreenSize() + // layer.copyToOffscreen() + // } /** * Renders the lines between the intact ranges when an update has pending @@ -440,20 +441,21 @@ export default class CanvasDrawer extends Mixin { * @param {number} firstRow the first row of the rendered region * @param {number} lastRow the last row of the rendered region * @access private + * Unused (inlined the code for performance reasons) */ - drawLinesForRanges (method, ranges, firstRow, lastRow) { - let currentRow = firstRow - for (let i = 0, len = ranges.length; i < len; i++) { - const range = ranges[i] - - method.call(this, currentRow, range.start, currentRow - firstRow) - - currentRow = range.end - } - if (currentRow <= lastRow) { - method.call(this, currentRow, lastRow, currentRow - firstRow) - } - } + // drawLinesForRanges (method, ranges, firstRow, lastRow) { + // let currentRow = firstRow + // for (let i = 0, len = ranges.length; i < len; i++) { + // const range = ranges[i] + // + // method.call(this, currentRow, range.start, currentRow - firstRow) + // + // currentRow = range.end + // } + // if (currentRow <= lastRow) { + // method.call(this, currentRow, lastRow, currentRow - firstRow) + // } + // } /** * Draws back decorations on the corresponding layer. From c3c1e5e9ff5791c7bcdac62bf9906f025186d823 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 2 Jan 2021 10:40:43 -0600 Subject: [PATCH 07/10] fix: take the const decorations out of loop --- lib/mixins/canvas-drawer.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index af20d6be..3a6128e2 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -135,8 +135,11 @@ export default class CanvasDrawer extends Mixin { const maxTokensInOneLine = this.maxTokensInOneLine this.updateTokensLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, context, editor, editorElement, displayCodeHighlights, ignoreWhitespacesInTokens, maxTokensInOneLine) - this.updateBackDecorationsLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) - this.updateFrontDecorationsLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + + const decorations = this.minimap.decorationsByTypeThenRows(firstRow, lastRow) + + this.updateBackDecorationsLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) + this.updateFrontDecorationsLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) this.pendingChanges = [] this.pendingBackDecorationChanges = [] @@ -226,9 +229,10 @@ export default class CanvasDrawer extends Mixin { * @param {number} canvasWidth this.tokensLayer.getSize().width * @param {number} canvasHeight this.tokensLayer.getSize().height * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() + * @param {Array} decorations * @access private */ - updateBackDecorationsLayer (firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) { + updateBackDecorationsLayer (firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) { const intactRanges = computeIntactRanges(firstRow, lastRow, this.pendingBackDecorationChanges, this.offscreenFirstRow, this.offscreenLastRow) // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately. @@ -238,7 +242,7 @@ export default class CanvasDrawer extends Mixin { this.backLayer.clearCanvas() if (intactRanges.length === 0) { - this.drawBackDecorationsForLines(firstRow, lastRow, 0, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + this.drawBackDecorationsForLines(firstRow, lastRow, 0, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) } else { for (let j = 0, len = intactRanges.length; j < len; j++) { const intact = intactRanges[j] @@ -254,12 +258,12 @@ export default class CanvasDrawer extends Mixin { for (let i = 0, len = intactRanges.length; i < len; i++) { const range = intactRanges[i] - this.drawBackDecorationsForLines(currentRow, range.start, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + this.drawBackDecorationsForLines(currentRow, range.start, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) currentRow = range.end } if (currentRow <= lastRow) { - this.drawBackDecorationsForLines(currentRow, lastRow, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + this.drawBackDecorationsForLines(currentRow, lastRow, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) } } @@ -280,9 +284,10 @@ export default class CanvasDrawer extends Mixin { * @param {number} canvasWidth this.tokensLayer.getSize().width * @param {number} canvasHeight this.tokensLayer.getSize().height * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() + * @param {Array} decorations * @access private */ - updateFrontDecorationsLayer (firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) { + updateFrontDecorationsLayer (firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) { const intactRanges = computeIntactRanges(firstRow, lastRow, this.pendingFrontDecorationChanges, this.offscreenFirstRow, this.offscreenLastRow) // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately. @@ -292,7 +297,7 @@ export default class CanvasDrawer extends Mixin { this.frontLayer.clearCanvas() if (intactRanges.length === 0) { - this.drawFrontDecorationsForLines(firstRow, lastRow, 0, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + this.drawFrontDecorationsForLines(firstRow, lastRow, 0, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) } else { for (let j = 0, len = intactRanges.length; j < len; j++) { const intact = intactRanges[j] @@ -308,12 +313,12 @@ export default class CanvasDrawer extends Mixin { for (let i = 0, len = intactRanges.length; i < len; i++) { const range = intactRanges[i] - this.drawFrontDecorationsForLines(currentRow, range.start, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + this.drawFrontDecorationsForLines(currentRow, range.start, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) currentRow = range.end } if (currentRow <= lastRow) { - this.drawFrontDecorationsForLines(currentRow, lastRow, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) + this.drawFrontDecorationsForLines(currentRow, lastRow, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) } } @@ -474,12 +479,12 @@ export default class CanvasDrawer extends Mixin { * @param {number} canvasWidth this.tokensLayer.getSize().width * @param {number} canvasHeight this.tokensLayer.getSize().height * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() + * @param {Array} decorations * @access private */ - drawBackDecorationsForLines (firstRow, lastRow, offsetRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) { + drawBackDecorationsForLines (firstRow, lastRow, offsetRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) { if (firstRow > lastRow) { return } - const decorations = this.minimap.decorationsByTypeThenRows(firstRow, lastRow) const renderData = { context: this.backLayer.context, canvasWidth, @@ -521,12 +526,12 @@ export default class CanvasDrawer extends Mixin { * @param {number} canvasWidth this.tokensLayer.getSize().width * @param {number} canvasHeight this.tokensLayer.getSize().height * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() + * @param {Array} decorations * @access private */ - drawFrontDecorationsForLines (firstRow, lastRow, offsetRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement) { + drawFrontDecorationsForLines (firstRow, lastRow, offsetRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) { if (firstRow > lastRow) { return } - const decorations = this.minimap.decorationsByTypeThenRows(firstRow, lastRow) const renderData = { context: this.frontLayer.context, canvasWidth, From 3b3dec1181243831dee4c79c164d1c3646fb80a2 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 2 Jan 2021 10:51:01 -0600 Subject: [PATCH 08/10] fix: factor out renderData from updateBackDecorationsLayer --- lib/mixins/canvas-drawer.js | 54 +++++++++++++------------------------ 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 3a6128e2..9b52c3f0 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -138,7 +138,17 @@ export default class CanvasDrawer extends Mixin { const decorations = this.minimap.decorationsByTypeThenRows(firstRow, lastRow) - this.updateBackDecorationsLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) + let renderData = { + context: this.backLayer.context, + canvasWidth, + canvasHeight, + lineHeight, + charWidth, + charHeight, + orders: Main.getPluginsOrder() + } + + this.updateBackDecorationsLayer(firstRow, lastRow, renderData, lineHeight, editorElement, decorations) this.updateFrontDecorationsLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) this.pendingChanges = [] @@ -223,16 +233,13 @@ export default class CanvasDrawer extends Mixin { * @param {number} firstRow firstRow the first row of the range to update * @param {number} lastRow lastRow the last row of the range to update * + * @param {Object} renderData * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio - * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio - * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio - * @param {number} canvasWidth this.tokensLayer.getSize().width - * @param {number} canvasHeight this.tokensLayer.getSize().height * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() * @param {Array} decorations * @access private */ - updateBackDecorationsLayer (firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) { + updateBackDecorationsLayer (firstRow, lastRow, renderData, lineHeight, editorElement, decorations) { const intactRanges = computeIntactRanges(firstRow, lastRow, this.pendingBackDecorationChanges, this.offscreenFirstRow, this.offscreenLastRow) // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately. @@ -242,7 +249,7 @@ export default class CanvasDrawer extends Mixin { this.backLayer.clearCanvas() if (intactRanges.length === 0) { - this.drawBackDecorationsForLines(firstRow, lastRow, 0, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) + this.drawBackDecorationsForLines(firstRow, lastRow, 0, renderData, lineHeight, editorElement, decorations) } else { for (let j = 0, len = intactRanges.length; j < len; j++) { const intact = intactRanges[j] @@ -258,12 +265,12 @@ export default class CanvasDrawer extends Mixin { for (let i = 0, len = intactRanges.length; i < len; i++) { const range = intactRanges[i] - this.drawBackDecorationsForLines(currentRow, range.start, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) + this.drawBackDecorationsForLines(currentRow, range.start, currentRow - firstRow, renderData, lineHeight, editorElement, decorations) currentRow = range.end } if (currentRow <= lastRow) { - this.drawBackDecorationsForLines(currentRow, lastRow, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) + this.drawBackDecorationsForLines(currentRow, lastRow, currentRow - firstRow, renderData, lineHeight, editorElement, decorations) } } @@ -473,28 +480,15 @@ export default class CanvasDrawer extends Mixin { * @param {number} offsetRow the relative offset to apply to rows when * rendering them * + * @param {Object} renderData * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio - * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio - * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio - * @param {number} canvasWidth this.tokensLayer.getSize().width - * @param {number} canvasHeight this.tokensLayer.getSize().height * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() * @param {Array} decorations * @access private */ - drawBackDecorationsForLines (firstRow, lastRow, offsetRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) { + drawBackDecorationsForLines (firstRow, lastRow, offsetRow, renderData, lineHeight, editorElement, decorations) { if (firstRow > lastRow) { return } - const renderData = { - context: this.backLayer.context, - canvasWidth, - canvasHeight, - lineHeight, - charWidth, - charHeight, - orders: Main.getPluginsOrder() - } - const drawCustomDecorationLambda = (decoration, data, decorationColor) => drawCustomDecoration(decoration, data, decorationColor, editorElement) backgroundDecorationDispatcher['background-custom'] = drawCustomDecorationLambda @@ -506,7 +500,7 @@ export default class CanvasDrawer extends Mixin { this.drawDecorations(screenRow, decorations, renderData, backgroundDecorationDispatcher, editorElement) } - this.backLayer.context.fill() + renderData.context.fill() } /** @@ -532,16 +526,6 @@ export default class CanvasDrawer extends Mixin { drawFrontDecorationsForLines (firstRow, lastRow, offsetRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) { if (firstRow > lastRow) { return } - const renderData = { - context: this.frontLayer.context, - canvasWidth, - canvasHeight, - lineHeight, - charWidth, - charHeight, - orders: Main.getPluginsOrder() - } - const drawCustomDecorationLambda = (decoration, data, decorationColor) => drawCustomDecoration(decoration, data, decorationColor, editorElement) frontDecorationDispatcher['foreground-custom'] = drawCustomDecorationLambda From 5e94c91b1846620a97db269f3350f773a7c956a5 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 2 Jan 2021 10:54:20 -0600 Subject: [PATCH 09/10] fix: factor out renderData from updateFrontDecorationsLayer --- lib/mixins/canvas-drawer.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 9b52c3f0..6d7f2494 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -138,7 +138,7 @@ export default class CanvasDrawer extends Mixin { const decorations = this.minimap.decorationsByTypeThenRows(firstRow, lastRow) - let renderData = { + const renderData = { context: this.backLayer.context, canvasWidth, canvasHeight, @@ -149,7 +149,10 @@ export default class CanvasDrawer extends Mixin { } this.updateBackDecorationsLayer(firstRow, lastRow, renderData, lineHeight, editorElement, decorations) - this.updateFrontDecorationsLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) + + renderData.context = this.frontLayer.context + + this.updateFrontDecorationsLayer(firstRow, lastRow, renderData, lineHeight, editorElement, decorations) this.pendingChanges = [] this.pendingBackDecorationChanges = [] @@ -285,16 +288,13 @@ export default class CanvasDrawer extends Mixin { * @param {number} firstRow firstRow the first row of the range to update * @param {number} lastRow lastRow the last row of the range to update * + * @param {Object} renderData * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio - * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio - * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio - * @param {number} canvasWidth this.tokensLayer.getSize().width - * @param {number} canvasHeight this.tokensLayer.getSize().height * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() * @param {Array} decorations * @access private */ - updateFrontDecorationsLayer (firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) { + updateFrontDecorationsLayer (firstRow, lastRow, renderData, lineHeight, editorElement, decorations) { const intactRanges = computeIntactRanges(firstRow, lastRow, this.pendingFrontDecorationChanges, this.offscreenFirstRow, this.offscreenLastRow) // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately. @@ -304,7 +304,7 @@ export default class CanvasDrawer extends Mixin { this.frontLayer.clearCanvas() if (intactRanges.length === 0) { - this.drawFrontDecorationsForLines(firstRow, lastRow, 0, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) + this.drawFrontDecorationsForLines(firstRow, lastRow, 0, renderData, lineHeight, editorElement, decorations) } else { for (let j = 0, len = intactRanges.length; j < len; j++) { const intact = intactRanges[j] @@ -320,12 +320,12 @@ export default class CanvasDrawer extends Mixin { for (let i = 0, len = intactRanges.length; i < len; i++) { const range = intactRanges[i] - this.drawFrontDecorationsForLines(currentRow, range.start, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) + this.drawFrontDecorationsForLines(currentRow, range.start, currentRow - firstRow, renderData, lineHeight, editorElement, decorations) currentRow = range.end } if (currentRow <= lastRow) { - this.drawFrontDecorationsForLines(currentRow, lastRow, currentRow - firstRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) + this.drawFrontDecorationsForLines(currentRow, lastRow, currentRow - firstRow, renderData, lineHeight, editorElement, decorations) } } @@ -514,16 +514,13 @@ export default class CanvasDrawer extends Mixin { * @param {number} offsetRow the relative offset to apply to rows when * rendering them * + * @param {Object} renderData * @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio - * @param {number} charHeight this.minimap.getCharHeight() * devicePixelRatio - * @param {number} charWidth this.minimap.getCharWidth() * devicePixelRatio - * @param {number} canvasWidth this.tokensLayer.getSize().width - * @param {number} canvasHeight this.tokensLayer.getSize().height * @param {TextEditorElement} editorElement this.minimap.getTextEditorElement() * @param {Array} decorations * @access private */ - drawFrontDecorationsForLines (firstRow, lastRow, offsetRow, lineHeight, charHeight, charWidth, canvasWidth, canvasHeight, editorElement, decorations) { + drawFrontDecorationsForLines (firstRow, lastRow, offsetRow, renderData, lineHeight, editorElement, decorations) { if (firstRow > lastRow) { return } const drawCustomDecorationLambda = (decoration, data, decorationColor) => drawCustomDecoration(decoration, data, decorationColor, editorElement) From 173454be8239ef5e18b3bd9a50ab26501a2dc4c2 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 2 Jan 2021 10:58:57 -0600 Subject: [PATCH 10/10] fix: inline variables used once in updateCanvas --- lib/mixins/canvas-drawer.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 6d7f2494..14960097 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -127,14 +127,10 @@ export default class CanvasDrawer extends Mixin { const charHeight = this.minimap.getCharHeight() * devicePixelRatio const charWidth = this.minimap.getCharWidth() * devicePixelRatio const { width: canvasWidth, height: canvasHeight } = this.tokensLayer.getSize() - const context = this.tokensLayer.context const editor = this.minimap.getTextEditor() const editorElement = this.minimap.getTextEditorElement() - const displayCodeHighlights = this.displayCodeHighlights - const ignoreWhitespacesInTokens = this.ignoreWhitespacesInTokens - const maxTokensInOneLine = this.maxTokensInOneLine - this.updateTokensLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, context, editor, editorElement, displayCodeHighlights, ignoreWhitespacesInTokens, maxTokensInOneLine) + this.updateTokensLayer(firstRow, lastRow, lineHeight, charHeight, charWidth, canvasWidth, this.tokensLayer.context, editor, editorElement, this.displayCodeHighlights, this.ignoreWhitespacesInTokens, this.maxTokensInOneLine) const decorations = this.minimap.decorationsByTypeThenRows(firstRow, lastRow)