mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge pull request #15865 from atom/as-fix-marker-change-event-block-decorations
Don't throw when destroying block decorations inside marker change event
This commit is contained in:
@@ -2541,6 +2541,24 @@ describe('TextEditorComponent', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('does not throw exceptions when destroying a block decoration inside a marker change event (regression)', async () => {
|
||||
const {editor, component} = buildComponent({rowsPerTile: 3})
|
||||
|
||||
const marker = editor.markScreenPosition([2, 0])
|
||||
marker.onDidChange(() => { marker.destroy() })
|
||||
const item = document.createElement('div')
|
||||
editor.decorateMarker(marker, {type: 'block', item})
|
||||
|
||||
await component.getNextUpdatePromise()
|
||||
expect(item.nextSibling).toBe(lineNodeForScreenRow(component, 2))
|
||||
|
||||
marker.setBufferRange([[0, 0], [0, 0]])
|
||||
expect(marker.isDestroyed()).toBe(true)
|
||||
|
||||
await component.getNextUpdatePromise()
|
||||
expect(item.parentElement).toBeNull()
|
||||
})
|
||||
|
||||
it('does not attempt to render block decorations located outside the visible range', async () => {
|
||||
const {editor, component} = buildComponent({autoHeight: false, rowsPerTile: 2})
|
||||
await setEditorHeightInLines(component, 2)
|
||||
|
||||
@@ -2523,6 +2523,7 @@ class TextEditorComponent {
|
||||
didDestroyDisposable.dispose()
|
||||
|
||||
if (wasValid) {
|
||||
wasValid = false
|
||||
this.blockDecorationsToMeasure.delete(decoration)
|
||||
this.heightsByBlockDecoration.delete(decoration)
|
||||
this.blockDecorationsByElement.delete(element)
|
||||
|
||||
Reference in New Issue
Block a user