mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Merge pull request #15051 from atom/ns-mb-measurements-with-pending-updates
Fix exceptions when measuring pixel positions with pending content updates
This commit is contained in:
@@ -3335,6 +3335,15 @@ describe('TextEditorComponent', () => {
|
||||
expect(left).toBe(clientLeftForCharacter(referenceComponent, 12, 1) - referenceContentRect.left)
|
||||
}
|
||||
})
|
||||
|
||||
it('does not get the component into an inconsistent state when the model has unflushed changes (regression)', async () => {
|
||||
const {component, element, editor} = buildComponent({rowsPerTile: 2, autoHeight: false, text: ''})
|
||||
await setEditorHeightInLines(component, 10)
|
||||
|
||||
const updatePromise = editor.getBuffer().append("hi\n")
|
||||
component.screenPositionForPixelPosition({top: 800, left: 1})
|
||||
await updatePromise
|
||||
})
|
||||
})
|
||||
|
||||
describe('screenPositionForPixelPosition', () => {
|
||||
|
||||
@@ -251,20 +251,17 @@ class TextEditorComponent {
|
||||
|
||||
this.measureBlockDecorations()
|
||||
|
||||
this.measuredContent = false
|
||||
this.updateSyncBeforeMeasuringContent()
|
||||
if (useScheduler === true) {
|
||||
const scheduler = etch.getScheduler()
|
||||
scheduler.readDocument(() => {
|
||||
this.measureContentDuringUpdateSync()
|
||||
this.measuredContent = true
|
||||
scheduler.updateDocument(() => {
|
||||
this.updateSyncAfterMeasuringContent()
|
||||
})
|
||||
})
|
||||
} else {
|
||||
this.measureContentDuringUpdateSync()
|
||||
this.measuredContent = true
|
||||
this.updateSyncAfterMeasuringContent()
|
||||
}
|
||||
}
|
||||
@@ -341,6 +338,7 @@ class TextEditorComponent {
|
||||
}
|
||||
|
||||
updateSyncBeforeMeasuringContent () {
|
||||
this.measuredContent = false
|
||||
this.derivedDimensionsCache = {}
|
||||
this.updateModelSoftWrapColumn()
|
||||
if (this.pendingAutoscroll) {
|
||||
@@ -384,6 +382,8 @@ class TextEditorComponent {
|
||||
}
|
||||
this.pendingAutoscroll = null
|
||||
}
|
||||
|
||||
this.measuredContent = true
|
||||
}
|
||||
|
||||
updateSyncAfterMeasuringContent () {
|
||||
|
||||
Reference in New Issue
Block a user