mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Refacotor document controller launch
This commit is contained in:
parent
1a8bfa4bf1
commit
620b5f8b2c
@ -8,6 +8,7 @@
|
||||
- Display the current editor mode in the document inspector.
|
||||
- Improve VoiceOver support.
|
||||
- Deprecate exact recalculation of insertion points when documents are updated by external processes to improve application stability.
|
||||
- Improve stability of application launch behavior.
|
||||
- [non-AppStore ver.] Update Sparkle from 2.6.0 to 2.6.2 (security update).
|
||||
|
||||
|
||||
|
@ -114,11 +114,6 @@ private enum BundleIdentifier {
|
||||
UserDefaults.standard.migrateFontSetting()
|
||||
UserDefaults.standard.migrateOnLaunchSetting()
|
||||
}
|
||||
|
||||
ProcessInfo.processInfo.automaticTerminationSupportEnabled = true
|
||||
|
||||
// instantiate shared instances
|
||||
_ = DocumentController.shared
|
||||
}
|
||||
|
||||
|
||||
@ -208,12 +203,16 @@ private enum BundleIdentifier {
|
||||
}
|
||||
|
||||
|
||||
#if SPARKLE
|
||||
func applicationWillFinishLaunching(_ notification: Notification) {
|
||||
|
||||
ProcessInfo.processInfo.automaticTerminationSupportEnabled = true
|
||||
|
||||
_ = DocumentController.shared
|
||||
|
||||
#if SPARKLE
|
||||
UpdaterManager.shared.setup()
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
@ -253,6 +252,27 @@ private enum BundleIdentifier {
|
||||
}
|
||||
|
||||
|
||||
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
||||
|
||||
// not evaluated on the app launch (only on the *re*-open event)
|
||||
|
||||
// invoked only on the *re*-open event
|
||||
switch UserDefaults.standard[.noDocumentOnLaunchOption] {
|
||||
case .untitledDocument:
|
||||
if !flag {
|
||||
// show an untitled document before the app considers displaying the Open dialog
|
||||
NSDocumentController.shared.newDocument(nil)
|
||||
}
|
||||
return false
|
||||
case .openPanel:
|
||||
// the original behavior depends on whether iCloud is enabled:
|
||||
// -> On: the Open dialog
|
||||
// -> Off: an untitled document
|
||||
return true // entrust to `.applicationShouldOpenUntitledFile(_:)`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func application(_ sender: NSApplication, openFiles filenames: [String]) {
|
||||
|
||||
assert(Thread.isMainThread)
|
||||
|
@ -192,19 +192,6 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingChanging
|
||||
}
|
||||
|
||||
|
||||
override class var usesUbiquitousStorage: Bool {
|
||||
|
||||
// pretend as if iCloud storage is disabled to let the system give up opening the open panel on launch (2018-02 macOS 10.13)
|
||||
if UserDefaults.standard[.noDocumentOnLaunchOption] != .openPanel,
|
||||
NSDocumentController.shared.documents.isEmpty
|
||||
{
|
||||
return false
|
||||
}
|
||||
|
||||
return super.usesUbiquitousStorage
|
||||
}
|
||||
|
||||
|
||||
override class func canConcurrentlyReadDocuments(ofType: String) -> Bool {
|
||||
|
||||
true
|
||||
|
Loading…
Reference in New Issue
Block a user