Skip to content

Commit

Permalink
fix: make drawBackDecorationsForLines a free function
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 12, 2021
1 parent 6b97b7a commit b2e238a
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions lib/mixins/canvas-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export default class CanvasDrawer extends Mixin {
this.backLayer.clearCanvas()

if (intactRanges.length === 0) {
this.drawBackDecorationsForLines(firstRow, lastRow, 0, renderData, lineHeight, editorElement, decorations)
drawBackDecorationsForLines(firstRow, lastRow, 0, renderData, lineHeight, editorElement, decorations)
} else {
for (let j = 0, len = intactRanges.length; j < len; j++) {
const intact = intactRanges[j]
Expand All @@ -219,12 +219,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, renderData, lineHeight, editorElement, decorations)
drawBackDecorationsForLines(currentRow, range.start, currentRow - firstRow, renderData, lineHeight, editorElement, decorations)

currentRow = range.end
}
if (currentRow <= lastRow) {
this.drawBackDecorationsForLines(currentRow, lastRow, currentRow - firstRow, renderData, lineHeight, editorElement, decorations)
drawBackDecorationsForLines(currentRow, lastRow, currentRow - firstRow, renderData, lineHeight, editorElement, decorations)
}
}

Expand Down Expand Up @@ -352,37 +352,6 @@ export default class CanvasDrawer extends Mixin {
// method.call(this, currentRow, lastRow, currentRow - firstRow)
// }
// }

/**
* Draws back decorations on the corresponding layer.
*
* The lines range to draw is specified by the `firstRow` and `lastRow`
* parameters.
*
* @param {number} firstRow the first row to render
* @param {number} lastRow the last row to render
* @param {number} offsetRow the relative offset to apply to rows when
* rendering them
*
* @param {Object} renderData
* @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio
* @param {TextEditorElement} editorElement this.minimap.getTextEditorElement()
* @param {Array<Decoration>} decorations
* @access private
*/
drawBackDecorationsForLines (firstRow, lastRow, offsetRow, renderData, lineHeight, editorElement, decorations) {
if (firstRow > lastRow) { return }

for (let screenRow = firstRow; screenRow <= lastRow; screenRow++) {
renderData.row = offsetRow + (screenRow - firstRow)
renderData.yRow = renderData.row * lineHeight
renderData.screenRow = screenRow

drawDecorations(screenRow, decorations, renderData, backgroundDecorationDispatcher, editorElement)
}

renderData.context.fill()
}
}

// ######## ######## ### ## ##
Expand Down Expand Up @@ -853,6 +822,37 @@ function drawFrontDecorationsForLines (firstRow, lastRow, offsetRow, renderData,
renderData.context.fill()
}

/**
* Draws back decorations on the corresponding layer.
*
* The lines range to draw is specified by the `firstRow` and `lastRow`
* parameters.
*
* @param {number} firstRow the first row to render
* @param {number} lastRow the last row to render
* @param {number} offsetRow the relative offset to apply to rows when
* rendering them
*
* @param {Object} renderData
* @param {number} lineHeight this.minimap.getLineHeight() * devicePixelRatio
* @param {TextEditorElement} editorElement this.minimap.getTextEditorElement()
* @param {Array<Decoration>} decorations
* @access private
*/
function drawBackDecorationsForLines (firstRow, lastRow, offsetRow, renderData, lineHeight, editorElement, decorations) {
if (firstRow > lastRow) { return }

for (let screenRow = firstRow; screenRow <= lastRow; screenRow++) {
renderData.row = offsetRow + (screenRow - firstRow)
renderData.yRow = renderData.row * lineHeight
renderData.screenRow = screenRow

drawDecorations(screenRow, decorations, renderData, backgroundDecorationDispatcher, editorElement)
}

renderData.context.fill()
}

// ###### ####### ## ####### ######## ######
// ## ## ## ## ## ## ## ## ## ## ##
// ## ## ## ## ## ## ## ## ##
Expand Down

0 comments on commit b2e238a

Please sign in to comment.