mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Ignore null bytes when measuring character widths in React editor
Fixes #2391
This commit is contained in:
@@ -227,6 +227,11 @@ describe "EditorComponent", ->
|
||||
else
|
||||
[node]
|
||||
|
||||
describe "when the buffer contains null bytes", ->
|
||||
it "excludes the null byte from character measurement", ->
|
||||
editor.setText("a\0b")
|
||||
expect(editor.pixelPositionForScreenPosition([0, Infinity]).left).toEqual 2 * charWidth
|
||||
|
||||
describe "gutter rendering", ->
|
||||
[lineNumberHasClass, gutter] = []
|
||||
|
||||
|
||||
@@ -522,7 +522,7 @@ class DisplayBuffer extends Model
|
||||
charWidths = @getScopedCharWidths(token.scopes)
|
||||
for char in token.value
|
||||
return {top, left} if column is targetColumn
|
||||
left += charWidths[char] ? defaultCharWidth
|
||||
left += charWidths[char] ? defaultCharWidth unless char is '\0'
|
||||
column++
|
||||
{top, left}
|
||||
|
||||
|
||||
@@ -232,6 +232,8 @@ LinesComponent = React.createClass
|
||||
charWidths = editor.getScopedCharWidths(scopes)
|
||||
|
||||
for char in value
|
||||
continue if char is '\0'
|
||||
|
||||
unless charWidths[char]?
|
||||
unless textNode?
|
||||
rangeForMeasurement ?= document.createRange()
|
||||
|
||||
Reference in New Issue
Block a user