void () { initText(" ".repeat(100)); Document document = getDocument(getFile()); MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, getProject(), true); List<String> events = new ArrayList<>(); addMarkupListener(markupModel, events); RangeHighlighter highlighter = markupModel.addRangeHighlighter(10, 11, 1, null, HighlighterTargetArea.EXACT_RANGE); List<String> expected = new ArrayList<>(); assertEventsFired(expected, events, "(10,11): AA"); WriteAction.run(() -> document.deleteString(5, 20)); assertFalse(highlighter.isValid()); assertEventsFired(expected, events, "(10,11): BR", "(10,11): AR"); }