From b242f034b4064d37e32e684fa5acc301a0cca927 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 19 Apr 2017 16:46:17 -0600 Subject: [PATCH] Don't render decorations for invalidated markers --- spec/text-editor-component-spec.js | 13 +++++++++++++ src/decoration-manager.js | 1 + 2 files changed, 14 insertions(+) diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index a63921c91..832456b27 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -934,6 +934,19 @@ describe('TextEditorComponent', () => { expect(lineNodeForScreenRow(component, 2).classList.contains('b')).toBe(true) expect(lineNodeForScreenRow(component, 3).classList.contains('b')).toBe(true) }) + + it('does not decorate invalidated markers', async () => { + const {component, element, editor} = buildComponent() + const marker = editor.markScreenRange([[1, 0], [3, 0]], {invalidate: 'touch'}) + editor.decorateMarker(marker, {type: ['line', 'line-number'], class: 'a'}) + await component.getNextUpdatePromise() + expect(lineNodeForScreenRow(component, 2).classList.contains('a')).toBe(true) + + editor.getBuffer().insert([2, 0], 'x') + expect(marker.isValid()).toBe(false) + await component.getNextUpdatePromise() + expect(lineNodeForScreenRow(component, 2).classList.contains('a')).toBe(false) + }) }) describe('highlight decorations', () => { diff --git a/src/decoration-manager.js b/src/decoration-manager.js index 06dd3f2f5..e98731623 100644 --- a/src/decoration-manager.js +++ b/src/decoration-manager.js @@ -94,6 +94,7 @@ class DecorationManager { for (let i = 0; i < markers.length; i++) { const marker = markers[i] + if (!marker.isValid()) continue let decorationPropertiesForMarker = decorationPropertiesByMarker.get(marker) if (decorationPropertiesForMarker == null) {