Think of the diode as a component that has very low ON resistance \$R_{D(on)}\$, and very high OFF resistance \$R_{D(off)}\$. Also, assume that resistance R's value is chosen so that $$ R_{D(on)} \lll R \lll R_{D(off)} $$ Next, note that two separate signals are vying for control of the voltage at node \$V_O\$: the op amp's output signal \$V_{O}^\prime\$ and \$V_{ref}\$. Voltage \$V_{O}^\prime\$ connects to \$V_{O}\$ through the diode's resistance \$R_{D}\$. Voltage \$V_{ref}\$ connects to \$V_{O}\$ through resistance \$R\$. **Case 1: The diode is forward biased (it is ON).** <br/>In this case the diode's ON resistance is several orders of magnitude less than the resistor's resistance, i.e., \$R_{D(on)} \lll R\$. Current takes the path of least resistance. Therefore, voltage \$V_{O}^\prime\$ has the path of least resistance to node \$V_{O}\$, and \$V_{O}^\prime\$ (not \$V_{ref}\$) has the greatest influence in determining the voltage \$V_{O}\$. In this case, the resistor's job is to isolate voltage source \$V_{O}^\prime\$ from voltage souce \$V_{ref}\$ when the diode is ON. **Case 2: The diode IS NOT forward biased (it is OFF)** <br/>In this case the diode's OFF resistance is several orders of magnitude greater than the resistor's resistance, i.e., \$R \lll R_{D(off)}\$. Current takes the path of least resistance. Therefore, voltage \$V_{ref}\$ has the path of least resistance to node \$V_{O}\$, and \$V_{ref}\$ (not \$V_{O}^\prime\$) has the greatest influence in determining the voltage \$V_{O}\$. In other words, with the diode OFF, the voltage at node \$V_{O}\$ is pulled up to voltage \$V_{ref}\$ through resistor R.