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:
Nathan Sobo
2017-04-24 16:30:15 -06:00
committed by Antonio Scandurra
parent bd6eedcc88
commit c7228f6d81
2 changed files with 10 additions and 2 deletions

View File

@@ -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
})

View File

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