@@ -104,11 +104,10 @@ public class RealtimeSuggestionController {
104104 guard let focusElement = application. focusedElement else { return }
105105 let focusElementType = focusElement. description
106106 focusedUIElement = focusElement
107-
108- let fileURL = XcodeInspector . shared. activeDocumentURL
109-
107+
110108 Task { // Notify suggestion service for open file.
111109 try await Task . sleep ( nanoseconds: 500_000_000 )
110+ let fileURL = try await Environment . fetchCurrentFileURL ( )
112111 _ = try await Workspace . fetchOrCreateWorkspaceIfNeeded ( fileURL: fileURL)
113112 }
114113
@@ -119,6 +118,7 @@ public class RealtimeSuggestionController {
119118 editorObservationTask = nil
120119
121120 editorObservationTask = Task { [ weak self] in
121+ let fileURL = try await Environment . fetchCurrentFileURL ( )
122122 if let sourceEditor = self ? . sourceEditor {
123123 await PseudoCommandHandler ( ) . invalidateRealtimeSuggestionsIfNeeded (
124124 fileURL: fileURL,
@@ -143,6 +143,7 @@ public class RealtimeSuggestionController {
143143 await self . notifyEditingFileChange ( editor: focusElement)
144144 case kAXSelectedTextChangedNotification:
145145 guard let sourceEditor else { continue }
146+ let fileURL = XcodeInspector . shared. activeDocumentURL
146147 await PseudoCommandHandler ( ) . invalidateRealtimeSuggestionsIfNeeded (
147148 fileURL: fileURL,
148149 sourceEditor: sourceEditor
0 commit comments