There are still methods that will fail (crash) when we lack a document, but everything involved with constructing and displaying the view should not work even without a placeholder document.
If we ask for a non-existing font then we may get back the system default font and as most users expect a monospaced font, we take extra steps to catch this situation and switch to the default monospaced font.
For example users that are currently using Menlo may get into this situation on macOS 10.12 where Menlo has been removed.
Furthermore, when no font name is configured we also use the system’s default fixed width font.
The replacement API¹ did not appear until the 10.10 SDK, although it might be usable from 10.9.2, but as we currently support 10.8, we cannot use it.
¹ [[NSProcessInfo processInfo] operatingSystemVersion]
Prior to 10.8 we could not form weak references to NSWindowControllers and as a delegate’s superclass is unknown, and could very likely be a window controller, we could not use weak storage.
In general only the active view should respond to keys but we have the text view handle bundle items because they can provide actions that are not tied to text editing, for example “Build” or “Show SCM Actions”.
Ideally bundle items would (also) be handled by the window controller, but keyDown: is not commonly passed up the responder chain, so our window controller never sees any keys.
The way the system is designed is that the menu system will resolve keys (before the active view) and then send the menu item’s action up the responder chain, so views respond to actions rather than keys, but we cannot use this system for bundle items because it does not support multiple items with same key equivalent or scope selectors.
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.
Commit 8c19532531 broke it so that a digest would only be stored if one was already there, meaning that new users (since November 2015) would not see release notes after update.
This can be disabled using:
defaults write com.macromates.TextMate.preview disableBundleSuggestions -bool YES
Though the user can also hold option and select “Never” for a suggestions to never see that again, and once the user has a custom binding for a document’s type, no suggestion will be shown.
If OakDocument itself is unable to find one we look at the fileType .tm_properties setting, either looking it up using ‘attr.untitled’ for untitled documents, or ‘attr.file.unknown-type’ for documents with a path.
If nothing is found we fallback to ‘text.plain’.
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.
We now have an Objective-C type that can be used in the UI to show various properties of a bundle.
This commit breaks compatibility with the current bundles preferences page.
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.