int (int offset) { Document document = myEditor.getDocument(); if (offset == 0) { return 0; } int lineNumber = myEditor.offsetToLogicalPosition(offset).line; return document.getLineStartOffset(lineNumber); }