Skip to content

Commit

Permalink
🐛 Fix invisible characters improperly matched
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed May 5, 2016
1 parent c437655 commit fee318a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/mixins/canvas-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ export default class CanvasDrawer extends Mixin {
let tokens = []
let scopes = []
let textIndex = 0
// console.log(lineText, invisibleRegExp, lineText.replace(invisibleRegExp, ' '))
for (let tagCode of tagCodes) {
if (displayLayer.isOpenTagCode(tagCode)) {
scopes.push(displayLayer.tagForCode(tagCode))
Expand Down Expand Up @@ -503,13 +504,15 @@ export default class CanvasDrawer extends Mixin {
*/
getInvisibleRegExp () {
let invisibles = this.getTextEditor().getInvisibles()
let regexp = ''
if (invisibles.cr != null) { regexp += invisibles.cr + '|' }
if (invisibles.eol != null) { regexp += invisibles.eol + '|' }
if (invisibles.space != null) { regexp += invisibles.space + '|' }
if (invisibles.tab != null) { regexp += invisibles.tab + '|' }

return new RegExp(_.escapeRegExp(regexp.slice(0, -1)), 'g')
let regexp = []
if (invisibles.cr != null) { regexp.push(invisibles.cr) }
if (invisibles.eol != null) { regexp.push(invisibles.eol) }
if (invisibles.space != null) { regexp.push(invisibles.space) }
if (invisibles.tab != null) { regexp.push(invisibles.tab) }

return RegExp(regexp.filter((s) => {
return typeof s === 'string'
}).map(_.escapeRegExp).join('|'), 'g')
}

/**
Expand Down

0 comments on commit fee318a

Please sign in to comment.