@@ -162,34 +162,32 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
162162 )
163163 focusedWindow = window
164164
165- // should find a better solution to do this thread safe
166- Task { @MainActor in
167- focusedWindowObservations. forEach { $0. cancel ( ) }
168- focusedWindowObservations. removeAll ( )
169-
170- documentURL = window. documentURL
171- workspaceURL = window. workspaceURL
172- projectRootURL = window. projectRootURL
173-
174- window. $documentURL
175- . filter { $0 != . init( fileURLWithPath: " / " ) }
176- . receive ( on: DispatchQueue . main)
177- . sink { [ weak self] url in
178- self ? . documentURL = url
179- } . store ( in: & focusedWindowObservations)
180- window. $workspaceURL
181- . filter { $0 != . init( fileURLWithPath: " / " ) }
182- . receive ( on: DispatchQueue . main)
183- . sink { [ weak self] url in
184- self ? . workspaceURL = url
185- } . store ( in: & focusedWindowObservations)
186- window. $projectRootURL
187- . filter { $0 != . init( fileURLWithPath: " / " ) }
188- . receive ( on: DispatchQueue . main)
189- . sink { [ weak self] url in
190- self ? . projectRootURL = url
191- } . store ( in: & focusedWindowObservations)
192- }
165+ focusedWindowObservations. forEach { $0. cancel ( ) }
166+ focusedWindowObservations. removeAll ( )
167+
168+ documentURL = window. documentURL
169+ workspaceURL = window. workspaceURL
170+ projectRootURL = window. projectRootURL
171+
172+ window. $documentURL
173+ . filter { $0 != . init( fileURLWithPath: " / " ) }
174+ . receive ( on: DispatchQueue . main)
175+ . sink { [ weak self] url in
176+ self ? . documentURL = url
177+ } . store ( in: & focusedWindowObservations)
178+ window. $workspaceURL
179+ . filter { $0 != . init( fileURLWithPath: " / " ) }
180+ . receive ( on: DispatchQueue . main)
181+ . sink { [ weak self] url in
182+ self ? . workspaceURL = url
183+ } . store ( in: & focusedWindowObservations)
184+ window. $projectRootURL
185+ . filter { $0 != . init( fileURLWithPath: " / " ) }
186+ . receive ( on: DispatchQueue . main)
187+ . sink { [ weak self] url in
188+ self ? . projectRootURL = url
189+ } . store ( in: & focusedWindowObservations)
190+
193191 } else {
194192 let window = XcodeWindowInspector ( uiElement: window)
195193 focusedWindow = window
0 commit comments