Skip to content

Commit df20358

Browse files
committed
add 200ms delay
1 parent a6f2d9e commit df20358

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Slighlty delay rendering inline completion when user is typing"
4+
}

packages/amazonq/src/app/inline/completion.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,20 @@ ${itemLog}
386386
return []
387387
}
388388

389+
// delay the suggestion rendeing if user is actively typing
390+
// see https://github.com/aws/aws-toolkit-vscode/commit/a537602a96f498f372ed61ec9d82cf8577a9d854
391+
for (let i = 0; i < 30; i++) {
392+
const lastDocumentChange = this.documentEventListener.getLastDocumentChangeEvent(document.uri.fsPath)
393+
if (
394+
lastDocumentChange &&
395+
performance.now() - lastDocumentChange.timestamp < CodeWhispererConstants.inlineSuggestionShowDelay
396+
) {
397+
await sleep(CodeWhispererConstants.showRecommendationTimerPollPeriod)
398+
} else {
399+
break
400+
}
401+
}
402+
389403
// the user typed characters from invoking suggestion cursor position to receiving suggestion position
390404
const typeahead = document.getText(new Range(position, editor.selection.active))
391405

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ export const identityPoolID = 'us-east-1:70717e99-906f-4add-908c-bd9074a2f5b9'
184184
*/
185185
export const inlineCompletionsDebounceDelay = 200
186186

187+
// add 200ms more delay on top of inline default 30-50ms
188+
export const inlineSuggestionShowDelay = 200
189+
187190
export const referenceLog = 'Code Reference Log'
188191

189192
export const suggestionDetailReferenceText = (licenses: string) =>

0 commit comments

Comments
 (0)