Skip to content

Commit e6ca4d4

Browse files
committed
Merge branch 'feature/fix-command-dismiss-suggestions' into develop
2 parents f15a747 + 8e690b3 commit e6ca4d4

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Core/Sources/SuggestionWidget/FeatureReducers/PanelFeature.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ public struct PanelFeature: ReducerProtocol {
9595
return .none
9696

9797
case .switchToAnotherEditorAndUpdateContent:
98-
state.content.error = nil
99-
state.content.suggestion = nil
10098
return .run { send in
10199
guard let fileURL = await xcodeInspector.safe.realtimeActiveDocumentURL
102100
else { return }

Core/Sources/SuggestionWidget/WidgetWindowsController.swift

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

Comments
 (0)