subtract 1 from getSelectionEnd()