Adding check for whether the document can actually be saved or not.

fixes rSmart/issues#386