Fix stripping continuation prompts when copying from Qt console

Closes issue #4728.

Thanks to @y-p for tracking down an obscure problem.