Merge pull request #15528 from atom/as-fix-remeasuring-invalid-block-decorations

Don't remeasure invalid block decorations
This commit is contained in:
Antonio Scandurra
2017-09-02 11:41:58 +02:00
committed by GitHub
2 changed files with 19 additions and 1 deletions

View File

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

View File

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