Point (VisualPosition visible) { int y = visibleLineNumberToYPosition(visible.line); int logLine = visualToLogicalPosition(new VisualPosition(visible.line, 0)).line; int lineStartOffset; if (logLine == 0) { lineStartOffset = 0; } else { if (logLine >= myDocument.getLineCount()) { lineStartOffset = myDocument.getTextLength(); } else { lineStartOffset = myDocument.getLineStartOffset(logLine); } } int x = getTabbedTextWidth(lineStartOffset, visible); return new Point(x, y); }