mirror of
https://github.com/atom/atom.git
synced 2026-01-26 15:28:27 -05:00
Always invalidate yardstick measurements when the editor becomes visible
...because content could get reflowed and previous measurements might become inaccurate. Typically, this could occur when measuring while the editor is hidden: in that case, the yardstick would always report `0px` and save that position into the cache. Then, when the editor becomes visible again, the wrong `0px` value would be returned, thus causing cursors etc. to be displayed incorrectly. This was being shadowed by a bug in our measurements cache, but after fixing it in #12730 it started becoming evident.
This commit is contained in:
@@ -195,9 +195,10 @@ class TextEditorComponent
|
||||
|
||||
becameVisible: ->
|
||||
@updatesPaused = true
|
||||
if @invalidateMeasurementsWhenVisible
|
||||
@invalidateMeasurements()
|
||||
@invalidateMeasurementsWhenVisible = false
|
||||
# Always invalidate LinesYardstick measurements when the editor becomes
|
||||
# visible again, because content might have been reflowed and measurements
|
||||
# could be outdated.
|
||||
@invalidateMeasurements()
|
||||
@measureScrollbars() if @measureScrollbarsWhenShown
|
||||
@sampleFontStyling()
|
||||
@sampleBackgroundColors()
|
||||
@@ -937,11 +938,8 @@ class TextEditorComponent
|
||||
@invalidateMeasurements()
|
||||
|
||||
invalidateMeasurements: ->
|
||||
if @isVisible()
|
||||
@linesYardstick.invalidateCache()
|
||||
@presenter.measurementsChanged()
|
||||
else
|
||||
@invalidateMeasurementsWhenVisible = true
|
||||
@linesYardstick.invalidateCache()
|
||||
@presenter.measurementsChanged()
|
||||
|
||||
screenPositionForMouseEvent: (event, linesClientRect) ->
|
||||
pixelPosition = @pixelPositionForMouseEvent(event, linesClientRect)
|
||||
|
||||
Reference in New Issue
Block a user