mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Don't re-measure if editor has become invisible
This commit is contained in:
committed by
Antonio Scandurra
parent
7aec696bb5
commit
6e6dce21ee
@@ -2236,6 +2236,14 @@ describe('TextEditorComponent', () => {
|
||||
expect(element.querySelectorAll('.line:not(.dummy)').length).toBeLessThan(initialRenderedLineCount)
|
||||
verifyCursorPosition(component, cursorNode, 1, 29)
|
||||
})
|
||||
|
||||
it('gracefully handles the editor being hidden after a styling change', async () => {
|
||||
const {component, element, editor} = buildComponent({autoHeight: false})
|
||||
element.style.fontSize = parseInt(getComputedStyle(element).fontSize) + 5 + 'px'
|
||||
TextEditor.didUpdateStyles()
|
||||
element.style.display = 'none'
|
||||
await component.getNextUpdatePromise()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -166,15 +166,23 @@ class TextEditorComponent {
|
||||
}
|
||||
|
||||
updateSync (useScheduler = false) {
|
||||
this.updateScheduled = false
|
||||
|
||||
// Don't proceed if we know we are not visible
|
||||
if (!this.visible) return
|
||||
|
||||
this.updateScheduled = false
|
||||
if (this.resolveNextUpdatePromise) this.resolveNextUpdatePromise()
|
||||
// Don't proceed if we have to pay for a measurement anyway and detect
|
||||
// that we are no longer visible.
|
||||
if ((this.remeasureCharacterDimensions || this.remeasureAllBlockDecorations) && !this.isVisible()) {
|
||||
if (this.resolveNextUpdatePromise) this.resolveNextUpdatePromise()
|
||||
return
|
||||
}
|
||||
|
||||
const onlyBlinkingCursors = this.nextUpdateOnlyBlinksCursors
|
||||
this.nextUpdateOnlyBlinksCursors = null
|
||||
if (onlyBlinkingCursors) {
|
||||
this.updateCursorBlinkSync()
|
||||
if (this.resolveNextUpdatePromise) this.resolveNextUpdatePromise()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -202,6 +210,8 @@ class TextEditorComponent {
|
||||
this.measuredContent = true
|
||||
this.updateSyncAfterMeasuringContent()
|
||||
}
|
||||
|
||||
if (this.resolveNextUpdatePromise) this.resolveNextUpdatePromise()
|
||||
}
|
||||
|
||||
measureBlockDecorations () {
|
||||
|
||||
Reference in New Issue
Block a user