Fix StringIndexOutOfBoundsException in SelectionUtil.getSelectionText()