From 359a30c0d334fdb79b9d9e973b382a7e88b09d5f Mon Sep 17 00:00:00 2001 From: abe33 Date: Wed, 20 Apr 2016 20:05:04 +0200 Subject: [PATCH] :racehorse: No need to paint tokens with only whitespaces --- lib/mixins/canvas-drawer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 145955c3..06b014e0 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -470,8 +470,12 @@ export default class CanvasDrawer extends Mixin { for (let tokens of this.tokenLinesForScreenRows(firstRow, lastRow)) { let x = 0 for (let token of tokens) { - const color = displayCodeHighlights ? this.getTokenColor(token) : this.getDefaultColor() - x = this.drawToken(context, token.value, color, x, y, charWidth, charHeight) + if (/^\s+$/.test(token.value)) { + x += token.value.length * charWidth + } else { + const color = displayCodeHighlights ? this.getTokenColor(token) : this.getDefaultColor() + x = this.drawToken(context, token.value, color, x, y, charWidth, charHeight) + } if (x > canvasWidth) { break } }