File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
Core/Sources/XcodeInspector Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -108,23 +108,29 @@ public final class XcodeInspector: ObservableObject {
108108 latestActiveXcode = xcode
109109 activeDocumentURL = xcode. documentURL
110110 focusedWindow = xcode. focusedWindow
111+
112+ let setFocusedElement = { [ weak self] in
113+ guard let self else { return }
114+ focusedElement = xcode. appElement. focusedElement
115+ if let editorElement = focusedElement, editorElement. isSourceEditor {
116+ focusedEditor = . init(
117+ runningApplication: xcode. runningApplication,
118+ element: editorElement
119+ )
120+ } else {
121+ focusedEditor = nil
122+ }
123+ }
111124
125+ setFocusedElement ( )
112126 let focusedElementChanged = Task { @MainActor in
113127 let notification = AXNotificationStream (
114128 app: xcode. runningApplication,
115129 notificationNames: kAXFocusedUIElementChangedNotification
116130 )
117131 for await _ in notification {
118132 try Task . checkCancellation ( )
119- focusedElement = xcode. appElement. focusedElement
120- if let editorElement = focusedElement, editorElement. isSourceEditor {
121- focusedEditor = . init(
122- runningApplication: xcode. runningApplication,
123- element: editorElement
124- )
125- } else {
126- focusedEditor = nil
127- }
133+ setFocusedElement ( )
128134 }
129135 }
130136
You can’t perform that action at this time.
0 commit comments