I realized that the navigateLineEnd() will be different if the selection is backwards, so I left in the selectionLead/Anchor logic.