Wait for the paste event to complete before trying to read the results

Necessary when pasting using the mouse
Merge remote-tracking branch 'fixpasteevent/paste-events'
Merge branch 'master' into custom