Ensure selection base is updated when deleting surrogates
This fixes a bug in which the selection base was not updated when
deleting at index of the trailing char of a Unicode surrogate,
introduced in d3149a5875.
Minor refactor to consolidate logic around NSRange.