mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user