Show warning if undo will delete non-empty document

Closes #1197