Skip to content

Commit da7c716

Browse files
committed
fix(amazonq): nep typeahead
1 parent 496e076 commit da7c716

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

aws-toolkit-vscode.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
{
1313
"path": "packages/amazonq",
1414
},
15+
{
16+
"path": "../language-servers",
17+
},
1518
],
1619
"settings": {
1720
"typescript.tsdk": "node_modules/typescript/lib",

packages/amazonq/.vscode/launch.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
1414
"env": {
1515
"SSMDOCUMENT_LANGUAGESERVER_PORT": "6010",
16-
"WEBPACK_DEVELOPER_SERVER": "http://localhost:8080"
16+
"WEBPACK_DEVELOPER_SERVER": "http://localhost:8080",
1717
// Below allows for overrides used during development
18-
// "__AMAZONQLSP_PATH": "${workspaceFolder}/../../../language-servers/app/aws-lsp-codewhisperer-runtimes/out/agent-standalone.js",
19-
// "__AMAZONQLSP_UI": "${workspaceFolder}/../../../language-servers/chat-client/build/amazonq-ui.js"
18+
"__AMAZONQLSP_PATH": "${workspaceFolder}/../../../language-servers/app/aws-lsp-codewhisperer-runtimes/out/agent-standalone.js",
19+
"__AMAZONQLSP_UI": "${workspaceFolder}/../../../language-servers/chat-client/build/amazonq-ui.js"
2020
},
2121
"envFile": "${workspaceFolder}/.local.env",
2222
"outFiles": ["${workspaceFolder}/dist/**/*.js", "${workspaceFolder}/../core/dist/**/*.js"],

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

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -239,30 +239,41 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
239239
const editor = window.activeTextEditor
240240
if (prevSession && prevSessionId && prevItemId && prevStartPosition) {
241241
const prefix = document.getText(new Range(prevStartPosition, position))
242-
const prevItemMatchingPrefix = []
242+
const prevItemMatchingPrefix: InlineCompletionItemWithReferences[] = []
243243
for (const item of this.sessionManager.getActiveRecommendation()) {
244244
const text = typeof item.insertText === 'string' ? item.insertText : item.insertText.value
245-
if (text.startsWith(prefix) && position.isAfterOrEqual(prevStartPosition)) {
246-
item.command = {
247-
command: 'aws.amazonq.acceptInline',
248-
title: 'On acceptance',
249-
arguments: [
250-
prevSessionId,
251-
item,
252-
editor,
253-
prevSession?.requestStartTime,
254-
position.line,
255-
prevSession?.firstCompletionDisplayLatency,
256-
],
245+
if (prefix.length > 0 && text.startsWith(prefix) && position.isAfterOrEqual(prevStartPosition)) {
246+
if (item.isInlineEdit) {
247+
prevItemMatchingPrefix.push(item)
248+
} else {
249+
item.command = {
250+
command: 'aws.amazonq.acceptInline',
251+
title: 'On acceptance',
252+
arguments: [
253+
prevSessionId,
254+
item,
255+
editor,
256+
prevSession?.requestStartTime,
257+
position.line,
258+
prevSession?.firstCompletionDisplayLatency,
259+
],
260+
}
261+
item.range = new Range(prevStartPosition, position)
262+
prevItemMatchingPrefix.push(item)
257263
}
258-
item.range = new Range(prevStartPosition, position)
259-
prevItemMatchingPrefix.push(item as InlineCompletionItem)
260264
}
261265
}
262266
// re-use previous suggestions as long as new typed prefix matches
263267
if (prevItemMatchingPrefix.length > 0) {
268+
if (prevItemMatchingPrefix[0].isInlineEdit) {
269+
// Check if Next Edit Prediction feature flag is enabled
270+
if (Experiments.instance.isExperimentEnabled('amazonqLSPNEP')) {
271+
void showEdits(prevItemMatchingPrefix[0], editor, prevSession, this.languageClient).then()
272+
}
273+
return []
274+
}
264275
getLogger().debug(`Re-using suggestions that match user typed characters`)
265-
return prevItemMatchingPrefix
276+
return prevItemMatchingPrefix as InlineCompletionItem[]
266277
}
267278
getLogger().debug(`Auto rejecting suggestions from previous session`)
268279
// if no such suggestions, report the previous suggestion as Reject

0 commit comments

Comments
 (0)