Fixed StringIndexOutOfBoundException when text is empty