File tree Expand file tree Collapse file tree 4 files changed +21
-7
lines changed
Expand file tree Collapse file tree 4 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -47,13 +47,14 @@ public final class Service {
4747 globalShortcutManager = . init( guiController: guiController)
4848
4949 #if canImport(ProService)
50- proService = withDependencies { dependencyValues in
51- dependencyValues . proServiceAcceptSuggestion = {
50+ proService = ProService (
51+ acceptSuggestion : {
5252 Task { await PseudoCommandHandler ( ) . acceptSuggestion ( ) }
53+ } ,
54+ dismissSuggestion: {
55+ Task { await PseudoCommandHandler ( ) . dismissSuggestion ( ) }
5356 }
54- } operation: {
55- ProService ( )
56- }
57+ )
5758 #endif
5859
5960 scheduledCleaner. service = self
@@ -92,7 +93,7 @@ public extension Service {
9293 reply ( nil , error)
9394 return
9495 }
95-
96+
9697 reply ( nil , XPCRequestNotHandledError ( ) )
9798 }
9899}
Original file line number Diff line number Diff line change @@ -241,6 +241,15 @@ struct PseudoCommandHandler {
241241 }
242242 }
243243 }
244+
245+ func dismissSuggestion( ) async {
246+ guard let documentURL = XcodeInspector . shared. activeDocumentURL else { return }
247+ guard let ( _, filespace) = try ? await Service . shared. workspacePool
248+ . fetchOrCreateWorkspaceAndFilespace ( fileURL: documentURL) else { return }
249+
250+ await filespace. reset ( )
251+ PresentInWindowSuggestionPresenter ( ) . discardSuggestion ( fileURL: documentURL)
252+ }
244253}
245254
246255extension PseudoCommandHandler {
Original file line number Diff line number Diff line change @@ -334,6 +334,10 @@ public extension UserDefaultPreferenceKeys {
334334 . init( defaultValue: true , key: " AcceptSuggestionWithTab " )
335335 }
336336
337+ var dismissSuggestionWithEsc : PreferenceKey < Bool > {
338+ . init( defaultValue: true , key: " DismissSuggestionWithEsc " )
339+ }
340+
337341 var isSuggestionSenseEnabled : PreferenceKey < Bool > {
338342 . init( defaultValue: false , key: " IsSuggestionSenseEnabled " )
339343 }
You can’t perform that action at this time.
0 commit comments