Skip to content

Commit

Permalink
fix: drawToken: use simple comparison instead of regex
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 7, 2021
1 parent a50fc65 commit fe56545
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/mixins/canvas-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,6 @@ function updateTokensLayer (tokensLayer, firstRow, lastRow, offscreenFirstRow, o

const emptyLineRegexp = /^\s+$/
const oneOrMoreWhiteSpaceRegexp = /\s+/
const whiteSpaceRegexp = /\s/

/**
* Draws a single token on the given context.
Expand Down Expand Up @@ -638,7 +637,7 @@ function drawToken (context, text, color, x, y, charWidth, charHeight, ignoreWhi
let chars = 0
for (let j = 0, len = text.length; j < len; j++) {
const char = text[j]
if (whiteSpaceRegexp.test(char)) {
if (char === ' ') {
if (chars > 0) {
context.fillRect(x - (chars * charWidth), y, chars * charWidth, charHeight)
}
Expand Down

0 comments on commit fe56545

Please sign in to comment.