Measure the rendered char width instead of the buffer char

If invisibles are turned on, the buffer char and the rendered char
may differ in size. For example, if `☃` is used as the tab invisible 
its width is probably larger than the width of a `\t`

Closes #1724
This commit is contained in:
Corey Johnson
2014-03-26 13:57:04 -07:00
parent dcf4394741
commit 50e045212b

View File

@@ -1338,14 +1338,17 @@ class EditorView extends View
return 0 if screenColumn == 0
tokenizedLine = @editor.displayBuffer.lineForRow(screenRow)
textContent = lineElement.textContent
left = 0
index = 0
for token in tokenizedLine.tokens
for char in token.value
for bufferChar in token.value
return left if index >= screenColumn
val = @getCharacterWidthCache(token.scopes, char)
# Invisibles might cause renderedChar to be different than bufferChar
renderedChar = textContent[index]
val = @getCharacterWidthCache(token.scopes, renderedChar)
if val?
left += val
else