Skip to content

Commit

Permalink
🐛 Fix invalid invisible regexp when show invisible is disabled
Browse files Browse the repository at this point in the history
Fixes #502
  • Loading branch information
abe33 committed Jun 14, 2016
1 parent 8d3ea20 commit 5b762a5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/mixins/canvas-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,11 @@ export default class CanvasDrawer extends Mixin {
} else if (displayLayer.isCloseTagCode(tagCode)) {
scopes.pop()
} else {
tokens.push({
value: lineText.substr(textIndex, tagCode).replace(invisibleRegExp, ' '),
scopes: scopes.slice()
})
let value = lineText.substr(textIndex, tagCode)
if (invisibleRegExp) {
value = value.replace(invisibleRegExp, ' ')
}
tokens.push({ value: value, scopes: scopes.slice() })
textIndex += tagCode
}
}
Expand Down Expand Up @@ -527,7 +528,7 @@ export default class CanvasDrawer extends Mixin {
if (invisibles.space != null) { regexp.push(invisibles.space) }
if (invisibles.tab != null) { regexp.push(invisibles.tab) }

return RegExp(regexp.filter((s) => {
return regexp.length === 0 ? null : RegExp(regexp.filter((s) => {
return typeof s === 'string'
}).map(_.escapeRegExp).join('|'), 'g')
}
Expand Down

0 comments on commit 5b762a5

Please sign in to comment.