Check the cursor position when deciding whether to save an undo item.

This ensures that the cursor position will be saved prior to running a transaction.

Fixes https://github.com/guardian/scribe/issues/309.