void (@NotNull Editor editor, @NotNull BitSet lines, @NotNull Caret caret) { Document document = editor.getDocument(); int totalLines = getLineCount(document); if (caret.hasSelection()) { int line1 = editor.offsetToLogicalPosition(caret.getSelectionStart()).line; int line2 = editor.offsetToLogicalPosition(caret.getSelectionEnd()).line; lines.set(line1, line2 + 1); if (caret.getSelectionEnd() == document.getTextLength()) lines.set(totalLines); } else { int offset = caret.getOffset(); VisualPosition visualPosition = caret.getVisualPosition(); Pair<LogicalPosition, LogicalPosition> pair = EditorUtil.calcSurroundingRange(editor, visualPosition, visualPosition); lines.set(pair.first.line, Math.max(pair.second.line, pair.first.line + 1)); if (offset == document.getTextLength()) lines.set(totalLines); } }