Skip to content

Commit a583915

Browse files
committed
Fix invalidating suggestion
1 parent 458b4eb commit a583915

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Core/Sources/Service/RealtimeSuggestionController.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)