Assign ::hasInvisibleCharacters on Token shims

This commit is contained in:
Nathan Sobo
2015-05-12 18:30:33 +02:00
parent 77e8a906c2
commit 2afe013f9e
2 changed files with 5 additions and 1 deletions

View File

@@ -21,7 +21,8 @@ class Token
hasInvisibleCharacters: false
constructor: (properties) ->
{@value, @scopes, @isAtomic, @bufferDelta, @isHardTab, @hasPairedCharacter, @isSoftWrapIndentation} = properties
{@value, @scopes, @isAtomic, @isHardTab, @bufferDelta} = properties
{@hasInvisibleCharacters, @hasPairedCharacter, @isSoftWrapIndentation} = properties
@firstNonWhitespaceIndex = properties.firstNonWhitespaceIndex ? null
@firstTrailingWhitespaceIndex = properties.firstTrailingWhitespaceIndex ? null

View File

@@ -155,6 +155,7 @@ class TokenizedLine
when HardTab
tokenProperties.isAtomic = true
tokenProperties.bufferDelta = 1
tokenProperties.hasInvisibleCharacters = true if @invisibles?.tab
when PairedCharacter
tokenProperties.isAtomic = true
tokenProperties.hasPairedCharacter = true
@@ -165,10 +166,12 @@ class TokenizedLine
if offset < @firstNonWhitespaceIndex
tokenProperties.firstNonWhitespaceIndex =
Math.min(tokenProperties.value.length, @firstNonWhitespaceIndex - offset)
tokenProperties.hasInvisibleCharacters = true if @invisibles?.space
if @lineEnding? and (offset + tokenProperties.value.length > @firstTrailingWhitespaceIndex)
tokenProperties.firstTrailingWhitespaceIndex =
Math.max(0, @firstTrailingWhitespaceIndex - offset)
tokenProperties.hasInvisibleCharacters = true if @invisibles?.space
offset += tokenProperties.value.length