mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge pull request #15528 from atom/as-fix-remeasuring-invalid-block-decorations
Don't remeasure invalid block decorations
This commit is contained in:
@@ -2371,6 +2371,23 @@ describe('TextEditorComponent', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('does not try to remeasure block decorations whose markers are invalid (regression)', async () => {
|
||||
const editor = buildEditor({rowsPerTile: 3, autoHeight: false})
|
||||
const {component, element} = buildComponent({editor, rowsPerTile: 3})
|
||||
const {decoration, marker} = createBlockDecorationAtScreenRow(editor, 2, {height: '12px', invalidate: 'touch'})
|
||||
editor.getBuffer().deleteRows(0, 3)
|
||||
await component.getNextUpdatePromise()
|
||||
|
||||
// Trigger a re-measurement of all block decorations.
|
||||
await setEditorWidthInCharacters(component, 20)
|
||||
assertLinesAreAlignedWithLineNumbers(component)
|
||||
assertTilesAreSizedAndPositionedCorrectly(component, [
|
||||
{tileStartRow: 0, height: 3 * component.getLineHeight()},
|
||||
{tileStartRow: 3, height: 3 * component.getLineHeight()},
|
||||
{tileStartRow: 6, height: 3 * component.getLineHeight()}
|
||||
])
|
||||
})
|
||||
|
||||
it('measures block decorations correctly when they are added before the component width has been updated', async () => {
|
||||
{
|
||||
const {editor, component, element} = buildComponent({autoHeight: false, width: 500, attach: false})
|
||||
|
||||
@@ -286,7 +286,8 @@ class TextEditorComponent {
|
||||
const decorations = this.props.model.getDecorations()
|
||||
for (var i = 0; i < decorations.length; i++) {
|
||||
const decoration = decorations[i]
|
||||
if (decoration.getProperties().type === 'block') {
|
||||
const marker = decoration.getMarker()
|
||||
if (marker.isValid() && decoration.getProperties().type === 'block') {
|
||||
this.blockDecorationsToMeasure.add(decoration)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user