looks good to me
Good to hear. Would it be OK if I push the change to this PR so we don't have to open another one?
additionally there is another scenario of creation of non-empty document which is Document->Clone
it is not considered by this code but seems to work ok anyway
And other from the plugins - e.g. the VC plugin shows git history in a non-saved tab. But you can start editing this document and then you probably want it to be persistent with this feature (on the other hand, when you don't edit it, you just want to close it without any warning which is why I added the modification check).