mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Merge pull request #15313 from atom/as-fix-extra-schedule-update
Ensure extra document updates are not scheduled during `updateSync`
This commit is contained in:
@@ -3610,6 +3610,23 @@ describe('TextEditorComponent', () => {
|
||||
element.style.display = 'none'
|
||||
await component.getNextUpdatePromise()
|
||||
})
|
||||
|
||||
it('does not throw an exception when the editor is soft-wrapped and changing the font size changes also the longest screen line', async () => {
|
||||
const {component, element, editor} = buildComponent({rowsPerTile: 3, autoHeight: false})
|
||||
editor.setText(
|
||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do\n' +
|
||||
'eiusmod tempor incididunt ut labore et dolore magna' +
|
||||
'aliqua. Ut enim ad minim veniam, quis nostrud exercitation'
|
||||
)
|
||||
editor.setSoftWrapped(true)
|
||||
await setEditorHeightInLines(component, 2)
|
||||
await setEditorWidthInCharacters(component, 56)
|
||||
await setScrollTop(component, 3 * component.getLineHeight())
|
||||
|
||||
element.style.fontSize = '20px'
|
||||
TextEditor.didUpdateStyles()
|
||||
await component.getNextUpdatePromise()
|
||||
})
|
||||
})
|
||||
|
||||
describe('synchronous updates', () => {
|
||||
|
||||
@@ -213,15 +213,17 @@ class TextEditorComponent {
|
||||
}
|
||||
|
||||
updateSync (useScheduler = false) {
|
||||
this.updateScheduled = false
|
||||
|
||||
// Don't proceed if we know we are not visible
|
||||
if (!this.visible) return
|
||||
if (!this.visible) {
|
||||
this.updateScheduled = false
|
||||
return
|
||||
}
|
||||
|
||||
// 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()
|
||||
this.updateScheduled = false
|
||||
return
|
||||
}
|
||||
|
||||
@@ -230,6 +232,7 @@ class TextEditorComponent {
|
||||
if (useScheduler && onlyBlinkingCursors) {
|
||||
this.refs.cursorsAndInput.updateCursorBlinkSync(this.cursorsBlinkedOff)
|
||||
if (this.resolveNextUpdatePromise) this.resolveNextUpdatePromise()
|
||||
this.updateScheduled = false
|
||||
return
|
||||
}
|
||||
|
||||
@@ -266,6 +269,8 @@ class TextEditorComponent {
|
||||
this.measureContentDuringUpdateSync()
|
||||
this.updateSyncAfterMeasuringContent()
|
||||
}
|
||||
|
||||
this.updateScheduled = false
|
||||
}
|
||||
|
||||
measureBlockDecorations () {
|
||||
|
||||
Reference in New Issue
Block a user