void (int x, int y) { if (x < 0) { x = 0; } LogicalPosition pos = xyToLogicalPosition(new Point(x, y)); int columnNumber = pos.column; int lineNumber = pos.line; if (lineNumber >= myDocument.getLineCount()) { lineNumber = myDocument.getLineCount() - 1; } if (!mySettings.isVirtualSpace()) { if (lineNumber >= 0) { int lineEndOffset = myDocument.getLineEndOffset(lineNumber); int lineEndColumnNumber = calcColumnNumber(lineEndOffset, lineNumber); if (columnNumber > lineEndColumnNumber) { columnNumber = lineEndColumnNumber; } } } if (lineNumber < 0) { lineNumber = 0; columnNumber = 0; } if (!mySettings.isCaretInsideTabs()) { int offset = logicalPositionToOffset(new LogicalPosition(lineNumber, columnNumber)); CharSequence text = myDocument.getCharsSequence(); if (offset >= 0 && offset < myDocument.getTextLength()) { if (text.charAt(offset) == '\t') { columnNumber = calcColumnNumber(offset, lineNumber); } } } LogicalPosition pos1 = new LogicalPosition(lineNumber, columnNumber); getCaretModel().moveToLogicalPosition(pos1); }