Handle empty client rects in LinesYardstick

getBoundingClientRect returns garbage values if the range has zero
width, which it does in the case of a fold placeholder or any other
zero-width character.

Sometimes getClientRects() returns an empty list, so we fall back to the
bounding rect in these cases.
This commit is contained in:
Nathan Sobo
2016-04-04 18:08:34 -06:00
parent bbef4c67c3
commit 244f117d95

View File

@@ -108,4 +108,4 @@ class LinesYardstick
clientRectForRange: (textNode, startIndex, endIndex) ->
@rangeForMeasurement.setStart(textNode, startIndex)
@rangeForMeasurement.setEnd(textNode, endIndex)
@rangeForMeasurement.getBoundingClientRect()
@rangeForMeasurement.getClientRects()[0] ? @rangeForMeasurement.getBoundingClientRect()