Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/amazonq/src/app/inline/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
return []
}

const isAutoTrigger = context.triggerKind === InlineCompletionTriggerKind.Automatic
// there is a bug in VS Code, when hitting Enter, the context.triggerKind is Invoke (0)
// when hitting other keystrokes, the context.triggerKind is Automatic (1)
// we only mark option + C as manual trigger
// this is a workaround since the inlineSuggest.trigger command take no params
const isAutoTrigger = performance.now() - vsCodeState.lastManualTriggerTime > 50
if (isAutoTrigger && !CodeSuggestionsState.instance.isSuggestionsEnabled()) {
// return early when suggestions are disabled with auto trigger
return []
Expand Down Expand Up @@ -348,7 +352,10 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
this.languageClient,
document,
position,
context,
{
triggerKind: isAutoTrigger ? 1 : 0,
selectedCompletionInfo: context.selectedCompletionInfo,
},
token,
isAutoTrigger,
getAllRecommendationsOptions,
Expand Down
2 changes: 2 additions & 0 deletions packages/amazonq/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
CodeWhispererSettings,
getSelectedCustomization,
TelemetryHelper,
vsCodeState,
} from 'aws-core-vscode/codewhisperer'
import {
Settings,
Expand Down Expand Up @@ -365,6 +366,7 @@ async function onLanguageServerReady(
sessionManager.checkInlineSuggestionVisibility()
}),
Commands.register({ id: 'aws.amazonq.invokeInlineCompletion', autoconnect: true }, async () => {
vsCodeState.lastManualTriggerTime = performance.now()
await vscode.commands.executeCommand('editor.action.inlineSuggest.trigger')
}),
Commands.register('aws.amazonq.refreshAnnotation', async (forceProceed: boolean) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/codewhisperer/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ interface VsCodeState {
lastUserModificationTime: number

isFreeTierLimitReached: boolean

lastManualTriggerTime: number
}

export const vsCodeState: VsCodeState = {
Expand All @@ -52,6 +54,7 @@ export const vsCodeState: VsCodeState = {
isRecommendationsActive: false,
lastUserModificationTime: 0,
isFreeTierLimitReached: false,
lastManualTriggerTime: 0,
}

export interface CodeWhispererConfig {
Expand Down
Loading