some fixes for multiple-mode textinput

#4258 
Let's move this inside the if branch, as that's the only place it's used.