Skip to content

Commit c9d6f91

Browse files
authored
fix(amazonq): Add Open tab as params for inline completion (#7801)
## Problem aws/language-server-runtimes#638 The workspace.getAllTextDocuments() API only returns the open tabs that were clicked during this IDE session. If you open, close, reopen IDE, this API returns empty unless user re-click those files again. So we need to let IDE compute the list of open tab files and send it to language server ## Solution Pass open tabs from the IDE to language server. This is not customer facing so there is no change log needed. It merely brings back old functional code. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent e6311d9 commit c9d6f91

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
import { TelemetryHelper } from './telemetryHelper'
2222
import { ICursorUpdateRecorder } from './cursorUpdateManager'
2323
import { getLogger } from 'aws-core-vscode/shared'
24+
import { getOpenFilesInWindow } from 'aws-core-vscode/utils'
2425
import { asyncCallWithTimeout } from '../../util/timeoutUtil'
2526

2627
export interface GetAllRecommendationsOptions {
@@ -79,14 +80,15 @@ export class RecommendationService {
7980
contentChanges: documentChangeEvent.contentChanges.map((x) => x as TextDocumentContentChangeEvent),
8081
}
8182
: undefined
82-
83+
const openTabs = await getOpenFilesInWindow()
8384
let request: InlineCompletionWithReferencesParams = {
8485
textDocument: {
8586
uri: document.uri.toString(),
8687
},
8788
position,
8889
context,
8990
documentChangeParams: documentChangeParams,
91+
openTabFilepaths: openTabs,
9092
}
9193
if (options.editsStreakToken) {
9294
request = { ...request, partialResultToken: options.editsStreakToken }

packages/amazonq/test/unit/amazonq/apps/inline/recommendationService.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ describe('RecommendationService', () => {
147147
position: mockPosition,
148148
context: mockContext,
149149
documentChangeParams: undefined,
150+
openTabFilepaths: [],
150151
})
151152

152153
// Verify session management
@@ -189,6 +190,7 @@ describe('RecommendationService', () => {
189190
position: mockPosition,
190191
context: mockContext,
191192
documentChangeParams: undefined,
193+
openTabFilepaths: [],
192194
}
193195
const secondRequestArgs = sendRequestStub.secondCall.args[1]
194196
assert.deepStrictEqual(firstRequestArgs, expectedRequestArgs)

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@
471471
"@aws-sdk/types": "^3.13.1",
472472
"@aws/chat-client": "^0.1.4",
473473
"@aws/chat-client-ui-types": "^0.1.47",
474-
"@aws/language-server-runtimes": "^0.2.111",
474+
"@aws/language-server-runtimes": "^0.2.119",
475475
"@aws/language-server-runtimes-types": "^0.1.47",
476476
"@cspotcode/source-map-support": "^0.8.1",
477477
"@sinonjs/fake-timers": "^10.0.2",

packages/core/src/shared/utilities/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export { VSCODE_EXTENSION_ID } from '../extensions'
88
export * from './functionUtils'
99
export * as messageUtils from './messages'
1010
export * as CommentUtils from './commentUtils'
11+
export * from './editorUtilities'

0 commit comments

Comments
 (0)