File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,14 +43,6 @@ public actor RealtimeSuggestionController {
4343 }
4444
4545 private func handleFocusElementChange( _ sourceEditor: SourceEditor ) {
46- Task { // Notify suggestion service for open file.
47- try await Task . sleep ( nanoseconds: 500_000_000 )
48- guard let fileURL = await XcodeInspector . shared. safe. realtimeActiveDocumentURL
49- else { return }
50- _ = try await Service . shared. workspacePool
51- . fetchOrCreateWorkspaceAndFilespace ( fileURL: fileURL)
52- }
53-
5446 self . sourceEditor = sourceEditor
5547
5648 let notificationsFromEditor = sourceEditor. axNotifications
Original file line number Diff line number Diff line change 1+ import Combine
12import Dependencies
23import Foundation
34import SuggestionService
@@ -33,6 +34,7 @@ public final class Service {
3334 #endif
3435
3536 @Dependency ( \. toast) var toast
37+ var cancellable = Set < AnyCancellable > ( )
3638
3739 private init ( ) {
3840 @Dependency ( \. workspacePool) var workspacePool
@@ -70,6 +72,19 @@ public final class Service {
7072 #endif
7173 DependencyUpdater ( ) . update ( )
7274 globalShortcutManager. start ( )
75+
76+ Task {
77+ await XcodeInspector . shared. safe. $activeDocumentURL
78+ . removeDuplicates ( )
79+ . filter { $0 != . init( fileURLWithPath: " / " ) }
80+ . compactMap { $0 }
81+ . sink { [ weak self] fileURL in
82+ Task {
83+ try await self ? . workspacePool
84+ . fetchOrCreateWorkspaceAndFilespace ( fileURL: fileURL)
85+ }
86+ } . store ( in: & cancellable)
87+ }
7388 }
7489}
7590
You can’t perform that action at this time.
0 commit comments