mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Only remeasure char widths on stylesheet changes if editor is visible
Fixes #2856
This commit is contained in:
@@ -1837,6 +1837,26 @@ describe "EditorComponent", ->
|
||||
line0Right = node.querySelector('.line > span:last-child').getBoundingClientRect().right
|
||||
expect(cursorLeft).toBe line0Right
|
||||
|
||||
describe "when stylesheets change while the editor is hidden", ->
|
||||
it "does not re-measure character widths until the editor is shown again", ->
|
||||
atom.config.set('editor.fontFamily', 'sans-serif')
|
||||
|
||||
wrapperView.hide()
|
||||
atom.themes.applyStylesheet 'test', """
|
||||
.function.js {
|
||||
font-weight: bold;
|
||||
}
|
||||
"""
|
||||
runSetImmediateCallbacks()
|
||||
|
||||
wrapperView.show()
|
||||
editor.setCursorBufferPosition([0, Infinity])
|
||||
runSetImmediateCallbacks()
|
||||
|
||||
cursorLeft = node.querySelector('.cursor').getBoundingClientRect().left
|
||||
line0Right = node.querySelector('.line > span:last-child').getBoundingClientRect().right
|
||||
expect(cursorLeft).toBe line0Right
|
||||
|
||||
describe "when lines are changed while the editor is hidden", ->
|
||||
it "does not measure new characters until the editor is shown again", ->
|
||||
editor.setText('')
|
||||
|
||||
@@ -801,7 +801,10 @@ EditorComponent = React.createClass
|
||||
@characterWidthRemeasurementRequested = true
|
||||
setImmediate =>
|
||||
@characterWidthRemeasurementRequested = false
|
||||
@remeasureCharacterWidths()
|
||||
if @state.visible
|
||||
@remeasureCharacterWidths()
|
||||
else
|
||||
@remeasureCharacterWidthsWhenShown = true
|
||||
|
||||
remeasureCharacterWidths: ->
|
||||
@remeasureCharacterWidthsWhenShown = false
|
||||
|
||||
Reference in New Issue
Block a user