Only remeasure char widths on stylesheet changes if editor is visible

Fixes #2856
This commit is contained in:
Nathan Sobo
2014-07-08 11:45:24 -06:00
parent 0793f291d1
commit 48d20ff1ec
2 changed files with 24 additions and 1 deletions

View File

@@ -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('')

View File

@@ -801,7 +801,10 @@ EditorComponent = React.createClass
@characterWidthRemeasurementRequested = true
setImmediate =>
@characterWidthRemeasurementRequested = false
@remeasureCharacterWidths()
if @state.visible
@remeasureCharacterWidths()
else
@remeasureCharacterWidthsWhenShown = true
remeasureCharacterWidths: ->
@remeasureCharacterWidthsWhenShown = false