Prefer replacing then deleting the selection to the other way around. This way less events need to be reported and the clipboard manager doesn't get confused. (cherry picked from commit 4150c1f0)