int (@NotNull EditorMouseEvent event) { Editor editor = event.getEditor(); if (event.getVisualPosition().line >= ((EditorImpl)editor).getVisibleLineCount()) { return -1; } int lineStartOffset = EditorUtil.getNotFoldedLineStartOffset(editor, event.getOffset()); int documentLine = editor.getDocument().getLineNumber(lineStartOffset); return documentLine < editor.getDocument().getLineCount() ? documentLine : -1; }