diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index 222b02492..311759bac 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -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}) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 78c003276..61868228b 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -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) } }