mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Fix error when attaching soft-wrap editor in synchronous update mode
Taking the initial measurement was setting the soft wrap column, which was triggering a display layer reset, which was scheduling an update. This update occurred at an unexpected time causing an exception.
This commit is contained in:
committed by
Antonio Scandurra
parent
bd6eedcc88
commit
c7228f6d81
@@ -2915,6 +2915,14 @@ describe('TextEditorComponent', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('does not throw an exception on attachment when setting the soft-wrap column', () => {
|
||||
const {component, element, editor} = buildComponent({width: 435, attach: false, updatedSynchronously: true})
|
||||
editor.setSoftWrapped(true)
|
||||
spyOn(window, 'onerror').andCallThrough()
|
||||
jasmine.attachToDOM(element) // should not throw an exception
|
||||
expect(window.onerror).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('updates synchronously when creating a component via TextEditor and TextEditorElement.prototype.updatedSynchronously is true', () => {
|
||||
TextEditorElement.prototype.setUpdatedSynchronously(true)
|
||||
const editor = buildEditor()
|
||||
@@ -3102,7 +3110,7 @@ function buildComponent (params = {}) {
|
||||
const component = new TextEditorComponent({
|
||||
model: editor,
|
||||
rowsPerTile: params.rowsPerTile,
|
||||
updatedSynchronously: false,
|
||||
updatedSynchronously: params.updatedSynchronously || false,
|
||||
platform: params.platform,
|
||||
mouseWheelScrollSensitivity: params.mouseWheelScrollSensitivity
|
||||
})
|
||||
|
||||
@@ -1182,8 +1182,8 @@ class TextEditorComponent {
|
||||
|
||||
didShow () {
|
||||
if (!this.visible && this.isVisible()) {
|
||||
this.visible = true
|
||||
if (!this.hasInitialMeasurements) this.measureDimensions()
|
||||
this.visible = true
|
||||
this.props.model.setVisible(true)
|
||||
this.updateSync()
|
||||
this.flushPendingLogicalScrollPosition()
|
||||
|
||||
Reference in New Issue
Block a user