void () { Document document = new DocumentImpl("\n\n\n\n\n"); MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, getProject(), true); RangeHighlighter h = model.addLineHighlighter(2, 0, null); model.addPersistentLineHighlighter(2, 0, null); WriteCommandAction.runWriteCommandAction(getProject(), () -> document.deleteString(1, 4)); assertFalse(h.isValid()); }