From a10def7ccf773e055cfad4be0779cebe74273a66 Mon Sep 17 00:00:00 2001 From: abe33 Date: Fri, 6 May 2016 10:16:35 +0200 Subject: [PATCH] :bug: Fix regression when reading tokens from line in old API For #343 --- lib/mixins/canvas-drawer.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 4afdc268..0913776e 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -415,13 +415,20 @@ export default class CanvasDrawer extends Mixin { let tokenLines = [] if (typeof editor.tokenizedLinesForScreenRows === 'function') { for (let tokenizedLine of editor.tokenizedLinesForScreenRows(startRow, endRow)) { - const invisibleRegExp = this.getInvisibleRegExpForLine(tokenizedLine) - tokenLines.push(tokenizedLine.tokens.map((token) => { + if (tokenizedLine) { + const invisibleRegExp = this.getInvisibleRegExpForLine(tokenizedLine) + tokenLines.push(tokenizedLine.tokens.map((token) => { + return { + value: token.value.replace(invisibleRegExp, ' '), + scopes: token.scopes.slice() + } + })) + } else { return { - value: token.value.replace(invisibleRegExp, ' '), - scopes: token.scopes.slice() + value: '', + scopes: [] } - })) + } } } else { const displayLayer = editor.displayLayer