Skip to content

Commit 5eb0973

Browse files
committed
Sync With AppKit
1 parent 44f1cd1 commit 5eb0973

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

CodeEdit/Features/Documents/Controllers/CodeEditDocumentController.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ final class CodeEditDocumentController: NSDocumentController {
9393
}
9494
}
9595

96-
override func clearRecentDocuments(_ sender: Any?) {
97-
super.clearRecentDocuments(sender)
98-
UserDefaults.standard.set([Any](), forKey: "recentProjectPaths")
99-
}
100-
10196
override func addDocument(_ document: NSDocument) {
10297
super.addDocument(document)
10398
if let document = document as? CodeFileDocument {

CodeEdit/Features/Welcome/Model/RecentProjectsStore.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ enum RecentProjectsStore {
4040

4141
// Limit list to to 100 items after de-duplication
4242
UserDefaults.standard.setValue(Array(paths.prefix(100)), forKey: defaultsKey)
43+
setDocumentControllerRecents()
4344
donateSearchableItems()
4445
NotificationCenter.default.post(name: Self.didUpdateNotification, object: nil)
4546
}
@@ -72,6 +73,15 @@ enum RecentProjectsStore {
7273
setPaths([])
7374
}
7475

76+
/// Syncs AppKit's recent documents list with ours, keeping the dock menu and other lists up-to-date.
77+
private static func setDocumentControllerRecents() {
78+
CodeEditDocumentController.shared.clearRecentDocuments(nil)
79+
for path in recentProjectURLs().prefix(10) {
80+
CodeEditDocumentController.shared.noteNewRecentDocumentURL(path)
81+
}
82+
}
83+
84+
/// Donates all recent URLs to Core Search, making them searchable in Spotlight
7585
private static func donateSearchableItems() {
7686
let searchableItems = recentProjectURLs().map { entity in
7787
let attributeSet = CSSearchableItemAttributeSet(contentType: .content)

0 commit comments

Comments
 (0)