void (final int offset, final boolean locateBeforeSoftWrap) { assertIsDispatchThread(); assertNotUpdating(); if (mySkipChangeRequests) { return; } myCaretModel.doWithCaretMerging(() -> { LogicalPosition logicalPosition = myEditor.offsetToLogicalPosition(offset); CaretEvent event = moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, null, true, false); final LogicalPosition positionByOffsetAfterMove = myEditor.offsetToLogicalPosition(getOffset()); if (!positionByOffsetAfterMove.equals(logicalPosition)) { StringBuilder debugBuffer = new StringBuilder(); moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, debugBuffer, true, true); int actualOffset = getOffset(); int textStart = Math.max(0, Math.min(offset, actualOffset) - 1); final DocumentEx document = myEditor.getDocument(); int textEnd = Math.min(document.getTextLength() - 1, Math.max(offset, actualOffset) + 1); CharSequence text = document.getCharsSequence().subSequence(textStart, textEnd); int inverseOffset = myEditor.logicalPositionToOffset(logicalPosition); LOG.error( "caret moved to wrong offset. Please submit a dedicated ticket and attach current editor's text to it.", new Throwable(), AttachmentFactory.createContext( "Requested: offset=" + offset + ", logical position='" + logicalPosition + "' but actual: offset=" + actualOffset + ", logical position='" + myLogicalCaret + "' (" + positionByOffsetAfterMove + "). " + myEditor.dumpState() + "\ninterested text [" + textStart + ";" + textEnd + "): '" + text + "'\n debug trace: " + debugBuffer + "\nLogical position -> offset ('" + logicalPosition + "'->'" + inverseOffset + "')")); } if (event != null) { myCaretModel.fireCaretPositionChanged(event); EditorActionUtil.selectNonexpandableFold(myEditor); } }); }