Skip to content

Commit

Permalink
🐛 Add guard when calling tokenLinesForScreenRows
Browse files Browse the repository at this point in the history
It should prevent #481 from happening
  • Loading branch information
abe33 committed May 20, 2016
1 parent 3a9d595 commit fc2622f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/mixins/canvas-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,17 @@ export default class CanvasDrawer extends Mixin {
const context = this.tokensLayer.context
const {width: canvasWidth} = this.tokensLayer.getSize()

if (!this.tokenLinesForScreenRows) { return }

const screenRowsTokens = this.tokenLinesForScreenRows(firstRow, lastRow)

let y = offsetRow * lineHeight
for (let tokens of this.tokenLinesForScreenRows(firstRow, lastRow)) {
for (let i = 0; i < screenRowsTokens.length; i++) {
let tokens = screenRowsTokens[i]
let x = 0
context.clearRect(x, y, canvasWidth, lineHeight)
for (let token of tokens) {
for (let j = 0; j < tokens.length; j++) {
let token = tokens[j]
if (/^\s+$/.test(token.value)) {
x += token.value.length * charWidth
} else {
Expand Down

0 comments on commit fc2622f

Please sign in to comment.