@@ -288,47 +288,53 @@ private extension WidgetWindowsController {
288288 observeToAppTask = Task {
289289 await windows. orderFront ( )
290290
291- let documentURL = await MainActor . run { store. withState { $0. focusingDocumentURL } }
292291 for await notification in await notifications. notifications ( ) {
293292 try Task . checkCancellation ( )
294293
295294 /// Hide the widgets before switching to another window/editor
296295 /// so the transition looks better.
297296 func hideWidgetForTransitions( ) async {
298297 let newDocumentURL = await xcodeInspector. safe. realtimeActiveDocumentURL
298+ let documentURL = await MainActor . run { store. withState { $0. focusingDocumentURL } }
299299 if documentURL != newDocumentURL {
300300 await send ( . panel( . removeDisplayedContent) )
301301 await hidePanelWindows ( )
302302 }
303303 await send ( . updateFocusingDocumentURL)
304304 }
305+
306+ func removeContent( ) async {
307+ await send ( . panel( . removeDisplayedContent) )
308+ }
305309
306310 func updateWidgetsAndNotifyChangeOfEditor( immediately: Bool ) async {
307311 await send ( . panel( . switchToAnotherEditorAndUpdateContent) )
308312 updateWindowLocation ( animated: false , immediately: immediately)
309313 updateWindowOpacity ( immediately: immediately)
310314 }
311315
312- func updateWidgets( ) async {
313- updateWindowLocation ( animated: false , immediately: false )
314- updateWindowOpacity ( immediately: false )
316+ func updateWidgets( immediately : Bool ) async {
317+ updateWindowLocation ( animated: false , immediately: immediately )
318+ updateWindowOpacity ( immediately: immediately )
315319 }
316320
317321 switch notification. kind {
318322 case . focusedWindowChanged, . focusedUIElementChanged:
319323 await hideWidgetForTransitions ( )
320324 await updateWidgetsAndNotifyChangeOfEditor ( immediately: true )
321325 case . applicationActivated:
326+ await removeContent ( )
322327 await updateWidgetsAndNotifyChangeOfEditor ( immediately: false )
323328 case . mainWindowChanged:
329+ await removeContent ( )
324330 await updateWidgetsAndNotifyChangeOfEditor ( immediately: false )
325331 case . moved,
326332 . resized,
327333 . windowMoved,
328334 . windowResized,
329335 . windowMiniaturized,
330336 . windowDeminiaturized:
331- await updateWidgets ( )
337+ await updateWidgets ( immediately : false )
332338 case . created, . uiElementDestroyed, . xcodeCompletionPanelChanged,
333339 . applicationDeactivated:
334340 continue
0 commit comments