Fix infinite loop with cua-mode and selection replacement with closing pair character