Do not rely on text anymore, check phantom tokens instead

This commit is contained in:
Antonio Scandurra
2015-02-16 15:47:17 +01:00
parent 131048af65
commit 38118b66cb
2 changed files with 5 additions and 2 deletions

View File

@@ -867,7 +867,7 @@ class DisplayBuffer extends Model
if /\s/.test(line.text[softWrapColumn])
# search forward for the start of a word past the boundary
for column in [softWrapColumn..line.text.length] when line.isOutsidePhantomToken(column)
for column in [softWrapColumn..line.text.length]
return column if /\S/.test(line.text[column])
return line.text.length
@@ -1164,7 +1164,7 @@ class DisplayBuffer extends Model
softWraps = 0
while wrapScreenColumn = @findWrapColumn(tokenizedLine)
[wrappedLine, tokenizedLine] = tokenizedLine.softWrapAt(wrapScreenColumn)
break if wrappedLine.text == tokenizedLine.text
break if wrappedLine.hasOnlyPhantomTokens()
screenLines.push(wrappedLine)
softWraps++
screenLines.push(tokenizedLine)

View File

@@ -130,6 +130,9 @@ class TokenizedLine
isInsidePhantomToken: (column) ->
@tokens[0].isPhantom && column < @tokens[0].screenDelta
hasOnlyPhantomTokens: ->
@tokens.length == 1 && @tokens[0].isPhantom
tokenAtBufferColumn: (bufferColumn) ->
@tokens[@tokenIndexAtBufferColumn(bufferColumn)]