VisualPosition (@NotNull Editor editor, int offset) { return ReadAction.compute(() -> { Editor e = editor; LogicalPosition logicalPosition = e.offsetToLogicalPosition(offset); if (e instanceof EditorWindow) { logicalPosition = ((EditorWindow)e).injectedToHost(logicalPosition); e = ((EditorWindow)e).getDelegate(); } VisualPosition pos = e.logicalToVisualPosition(logicalPosition); Inlay inlay; while ((inlay = e.getInlayModel().getInlineElementAt(pos)) != null) { if (inlay.isRelatedToPrecedingText()) break; pos = new VisualPosition(pos.line, pos.column + 1); } return pos; }); }