@@ -112,7 +112,6 @@ export class InlineCompletionManager implements Disposable {
112112 ) => {
113113 try {
114114 vsCodeState . isCodeWhispererEditing = true
115- const startLine = position . line
116115 // TODO: also log the seen state for other suggestions in session
117116 // Calculate timing metrics before diagnostic delay
118117 const totalSessionDisplayTime = performance . now ( ) - requestStartTime
@@ -121,11 +120,6 @@ export class InlineCompletionManager implements Disposable {
121120 this . sessionManager . getActiveSession ( ) ?. diagnosticsBeforeAccept ,
122121 getDiagnosticsOfCurrentFile ( )
123122 )
124- // try remove the extra } ) ' " if there is a new reported problem
125- // the extra } will cause syntax error
126- if ( diagnosticDiff . added . length > 0 ) {
127- await handleExtraBrackets ( editor , editor . selection . active , position )
128- }
129123 const params : LogInlineCompletionSessionResultsParams = {
130124 sessionId : sessionId ,
131125 completionSessionResult : {
@@ -170,22 +164,16 @@ export class InlineCompletionManager implements Disposable {
170164 const onInlineRejection = async ( ) => {
171165 try {
172166 vsCodeState . isCodeWhispererEditing = true
173- const session = this . sessionManager . getActiveSession ( )
174- if ( session === undefined ) {
175- return
176- }
177- const requestStartTime = session . requestStartTime
178- const totalSessionDisplayTime = performance . now ( ) - requestStartTime
179167 await commands . executeCommand ( 'editor.action.inlineSuggest.hide' )
180168 // TODO: also log the seen state for other suggestions in session
181169 this . disposable . dispose ( )
182170 this . disposable = languages . registerInlineCompletionItemProvider (
183171 CodeWhispererConstants . platformLanguageIds ,
184172 this . inlineCompletionProvider
185173 )
186- const sessionId = session . sessionId
174+ const sessionId = this . sessionManager . getActiveSession ( ) ? .sessionId
187175 const itemId = this . sessionManager . getActiveRecommendation ( ) [ 0 ] ?. itemId
188- if ( ! itemId ) {
176+ if ( ! sessionId || ! itemId ) {
189177 return
190178 }
191179 const params : LogInlineCompletionSessionResultsParams = {
@@ -197,8 +185,6 @@ export class InlineCompletionManager implements Disposable {
197185 discarded : false ,
198186 } ,
199187 } ,
200- firstCompletionDisplayLatency : session . firstCompletionDisplayLatency ,
201- totalSessionDisplayTime : totalSessionDisplayTime ,
202188 }
203189 this . languageClient . sendNotification ( this . logSessionResultMessageName , params )
204190 // clear session manager states once rejected
@@ -311,16 +297,21 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
311297 return [ ]
312298 }
313299
314- // there is a bug in VS Code, when hitting Enter, the context.triggerKind is Invoke (0)
315- // when hitting other keystrokes, the context.triggerKind is Automatic (1)
316- // we only mark option + C as manual trigger
317- // this is a workaround since the inlineSuggest.trigger command take no params
318- const isAutoTrigger = performance . now ( ) - vsCodeState . lastManualTriggerTime > 50
300+ const isAutoTrigger = context . triggerKind === InlineCompletionTriggerKind . Automatic
319301 if ( isAutoTrigger && ! CodeSuggestionsState . instance . isSuggestionsEnabled ( ) ) {
320302 // return early when suggestions are disabled with auto trigger
321303 return [ ]
322304 }
323305
306+ // yield event loop to let the document listen catch updates
307+ await sleep ( 1 )
308+ // prevent user deletion invoking auto trigger
309+ // this is a best effort estimate of deletion
310+ if ( this . documentEventListener . isLastEventDeletion ( document . uri . fsPath ) ) {
311+ getLogger ( ) . debug ( 'Skip auto trigger when deleting code' )
312+ return [ ]
313+ }
314+
324315 // yield event loop to let the document listen catch updates
325316 await sleep ( 1 )
326317
@@ -411,8 +402,8 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
411402 } ,
412403 token ,
413404 isAutoTrigger ,
414- this . documentEventListener ,
415- getAllRecommendationsOptions
405+ getAllRecommendationsOptions ,
406+ this . documentEventListener . getLastDocumentChangeEvent ( document . uri . fsPath ) ?. event
416407 )
417408 // get active item from session for displaying
418409 const items = this . sessionManager . getActiveRecommendation ( )
0 commit comments