void (PrintStream dumpStream) { dumpStream.println(mySearchResults.getFindModel()); if (myReplacementPreviewText != null) { dumpStream.println("--"); dumpStream.println("Replacement Preview: " + myReplacementPreviewText); } dumpStream.println("--"); Editor editor = mySearchResults.getEditor(); RangeHighlighter[] highlighters = editor.getMarkupModel().getAllHighlighters(); Arrays.sort(highlighters, Segment.BY_START_OFFSET_THEN_END_OFFSET); List<Pair<Integer, Character>> ranges = new ArrayList<>(); for (RangeHighlighter highlighter : highlighters) { ranges.add(new Pair<>(highlighter.getStartOffset(), '[')); ranges.add(new Pair<>(highlighter.getEndOffset(), ']')); } SelectionModel selectionModel = editor.getSelectionModel(); if (selectionModel.getSelectionStart() != selectionModel.getSelectionEnd()) { ranges.add(new Pair<>(selectionModel.getSelectionStart(), '<')); ranges.add(new Pair<>(selectionModel.getSelectionEnd(), '>')); } ranges.add(new Pair<>(-1, '\n')); ranges.add(new Pair<>(editor.getDocument().getTextLength() + 1, '\n')); ContainerUtil.sort(ranges, (pair, pair2) -> { int res = pair.first - pair2.first; if (res == 0) { Character c1 = pair.second; Character c2 = pair2.second; if (c1 == '<' && c2 == '[') { return 1; } else if (c1 == '[' && c2 == '<') { return -1; } return c1.compareTo(c2); } return res; }); Document document = editor.getDocument(); for (int i = 0; i < ranges.size()-1; ++i) { Pair<Integer, Character> pair = ranges.get(i); Pair<Integer, Character> pair1 = ranges.get(i + 1); dumpStream.print(pair.second + document.getText(TextRange.create(Math.max(pair.first, 0), Math.min(pair1.first, document.getTextLength())))); } dumpStream.println("\n--"); if (NotFound) { dumpStream.println("Not Found"); dumpStream.println("--"); NotFound = false; } for (RangeHighlighter highlighter : highlighters) { dumpStream.println(highlighter + " : " + highlighter.getTextAttributes(editor.getColorsScheme())); } dumpStream.println("------------"); }