@@ -136,14 +136,21 @@ struct PseudoCommandHandler {
136136 }
137137
138138 func acceptSuggestion( ) async {
139- if UserDefaults . shared. value ( for: \. acceptSuggestionWithAccessibilityAPI) {
139+ do {
140+ try await Environment . triggerAction ( " Accept Suggestion " )
141+ } catch {
140142 guard let xcode = ActiveApplicationMonitor . activeXcode ?? ActiveApplicationMonitor
141143 . latestXcode else { return }
142144 let application = AXUIElementCreateApplication ( xcode. processIdentifier)
143145 guard let focusElement = application. focusedElement,
144146 focusElement. description == " Source Editor "
145147 else { return }
146- guard let ( content, lines, _, cursorPosition) = await getFileContent ( sourceEditor: nil )
148+ guard let (
149+ content,
150+ lines,
151+ _,
152+ cursorPosition
153+ ) = await getFileContent ( sourceEditor: nil )
147154 else {
148155 PresentInWindowSuggestionPresenter ( )
149156 . presentErrorMessage ( " Unable to get file content. " )
@@ -199,21 +206,15 @@ struct PseudoCommandHandler {
199206 }
200207 }
201208
202- if let oldScrollPosition, let scrollBar = focusElement. parent? . verticalScrollBar {
209+ if let oldScrollPosition,
210+ let scrollBar = focusElement. parent? . verticalScrollBar
211+ {
203212 AXUIElementSetAttributeValue (
204213 scrollBar,
205214 kAXValueAttribute as CFString ,
206215 oldScrollPosition as CFTypeRef
207216 )
208217 }
209-
210- } catch {
211- PresentInWindowSuggestionPresenter ( ) . presentError ( error)
212- }
213- } else {
214- do {
215- try await Environment . triggerAction ( " Accept Suggestion " )
216- return
217218 } catch {
218219 PresentInWindowSuggestionPresenter ( ) . presentError ( error)
219220 }
0 commit comments