The function accepts two arguments that specify the start and the end of the text to select. Fixes #4164