Is this a Developer or End User issue? Meaning, are you writing code or are you just working in a document? If you are not a developer, you are on the wrong forum. With that said ...
If your document was save on OneDrive or DropBox or any other cloud based file system, you can probably recover a previous version on it.
The best and easiest recovery option though is from Time Machine, the built-in Mac backup program. Are you using it?
Kind Regards, Rich ... http://greatcirclelearning.com