Fix bug where end of smart selection was one place too early