Skip to content

Commit

Permalink
fix: call getTextEditorElement() outside of getDecorationColor
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 2, 2021
1 parent ad4fa0e commit 739a561
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/mixins/canvas-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,18 @@ export default class CanvasDrawer extends Mixin {
* its own `color` property.
*
* @param {Decoration} decoration the decoration to get the color for
* @param {TextEditorElement} editorElement
* @return {string} the CSS color for the provided decoration
*/
getDecorationColor (decoration) {
getDecorationColor (decoration, editorElement) {
const properties = decoration.getProperties()
if (properties.color) { return properties.color }

if (properties.scope) {
const scopeString = properties.scope.split(/\s+/)
return this.DOMStylesReader.retrieveStyleFromDom(scopeString, 'background-color', this.minimap.getTextEditorElement(), true)
return this.DOMStylesReader.retrieveStyleFromDom(scopeString, 'background-color', editorElement, true)
} else {
return this.getDefaultColor(this.minimap.getTextEditorElement())
return this.getDefaultColor(editorElement)
}
}

Expand Down Expand Up @@ -499,7 +500,7 @@ export default class CanvasDrawer extends Mixin {
* @access private
*/
drawLineDecoration (decoration, data) {
data.context.fillStyle = this.getDecorationColor(decoration)
data.context.fillStyle = this.getDecorationColor(decoration, this.minimap.getTextEditorElement())
data.context.fillRect(0, data.yRow, data.canvasWidth, data.lineHeight)
}

Expand All @@ -511,7 +512,7 @@ export default class CanvasDrawer extends Mixin {
* @access private
*/
drawGutterDecoration (decoration, data) {
data.context.fillStyle = this.getDecorationColor(decoration)
data.context.fillStyle = this.getDecorationColor(decoration, this.minimap.getTextEditorElement())
data.context.fillRect(0, data.yRow, 1, data.lineHeight)
}

Expand All @@ -529,7 +530,7 @@ export default class CanvasDrawer extends Mixin {
const range = decoration.getMarker().getScreenRange()
const rowSpan = range.end.row - range.start.row

data.context.fillStyle = this.getDecorationColor(decoration)
data.context.fillStyle = this.getDecorationColor(decoration, this.minimap.getTextEditorElement())

if (rowSpan === 0) {
const colSpan = range.end.column - range.start.column
Expand Down Expand Up @@ -562,7 +563,7 @@ export default class CanvasDrawer extends Mixin {
const yStart = data.yRow
const yEnd = yStart + lineHeight

data.context.fillStyle = this.getDecorationColor(decoration)
data.context.fillStyle = this.getDecorationColor(decoration, this.minimap.getTextEditorElement())

if (rowSpan === 0) {
colSpan = range.end.column - range.start.column
Expand Down Expand Up @@ -638,7 +639,7 @@ export default class CanvasDrawer extends Mixin {
const renderRoutine = decoration.getProperties().render

if (renderRoutine) {
data.color = this.getDecorationColor(decoration)
data.color = this.getDecorationColor(decoration, this.minimap.getTextEditorElement())
renderRoutine(decoration, data)
}
}
Expand Down

0 comments on commit 739a561

Please sign in to comment.