Fix cursor reset when removing whitespaces