RangeHighlighter (int startOffset, int endOffset, @NotNull TextAttributes attributes, int layer) { Project project = mySearchResults.getProject(); if (project.isDisposed()) return null; var markupModel = mySearchResults.getEditor().getMarkupModel(); var highlighter = markupModel.addRangeHighlighter(startOffset, endOffset, layer, attributes, HighlighterTargetArea.EXACT_RANGE); if (highlighter instanceof RangeHighlighterEx ex) ex.setVisibleIfFolded(true); return highlighter; }