This will also ensure the display name does not contain any slashes (which it can when a custom name is set) so that it is safe to use this as a filename.
A document has both a virtual and an actual path. The virtual path is relevant e.g. when opening files via rmate, where we want to lookup file-type specific settings based on the remote path (filename) rather than the local temporary file. However, if there is no virtual path, we should fallback on the actual path, which broke when we made document_t a wrapper for OakDocument.
There is now a new logical_path getter which return the virtual path and fallback on the actual path.
Closestextmate/bugs#21
This could lead to a crash if the second caller of load would access the document’s buffer (before the load initiated by first caller had finished).
Issue introduced in beta 11.
If there is no custom binding and no installed grammar matches the document (based on content or path extension) then we leave the document without a file type and expect the caller (of loadModalForWindow:completionHandler:) to set the file type (in the completion handler).
The caller can consult online bundles, present UI to the user, and also know about “project directory”, so they can make a better choice than the OakDocument.
The old implementation in document_t would check the status in the getter when the document wasn’t open, since we only observe the disk for open documents.
Such solution though would not support key/value observing.
We could improve performance slightly by accepting an “isOnDisk” flag in the initializer since when we create documents from scanning the disk (folder search and file chooser) we already know the document is on disk and thus could skip the extra disk access.
This is intentionally kept very similar to document_t so that we can make document_t a wrapper and once all document_t code has been migrated to OakDocument, we can extend the API like introducing an OakDocumentEditor and possibly make it an NSDocument subclass.
The implementation of OakDocument have some minor improvements over document_t for example when a document is changed on disk we delay reloading the changes until TextMate is made active, and we currently do not reload the content when there are merge conflicts (though we need to warn the user about this).
Minimum OS requirement is now OS X 10.8 because we use NSUUID.