Skip to content

Commit c0ffdb9

Browse files
author
Jiatong Li
committed
fix(codewhisperer): fix extractContextForCodeWhisperer tests
1 parent efda8d1 commit c0ffdb9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/amazonq/test/unit/codewhisperer/util/editorContext.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe('editorContext', function () {
5656
const editor = createMockTextEditor('import math\ndef two_sum(nums, target):\n', 'test.py', 'python', 1, 17)
5757
const actual = EditorContext.extractContextForCodeWhisperer(editor)
5858
const expected: codewhispererClient.FileContext = {
59+
fileUri: 'file:///test.py',
5960
filename: 'test.py',
6061
programmingLanguage: {
6162
languageName: 'python',
@@ -76,6 +77,7 @@ describe('editorContext', function () {
7677
)
7778
const actual = EditorContext.extractContextForCodeWhisperer(editor)
7879
const expected: codewhispererClient.FileContext = {
80+
fileUri: 'file:///test.py',
7981
filename: 'test.py',
8082
programmingLanguage: {
8183
languageName: 'python',
@@ -112,6 +114,7 @@ describe('editorContext', function () {
112114

113115
const actual = EditorContext.extractContextForCodeWhisperer(editor)
114116
const expected: codewhispererClient.FileContext = {
117+
fileUri: 'vscode-notebook-cell:Untitled-1.ipynb',
115118
filename: 'Untitled-1.py',
116119
programmingLanguage: {
117120
languageName: 'python',

packages/core/src/codewhisperer/util/editorContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function extractContextForCodeWhisperer(editor: vscode.TextEditor): codew
167167
}
168168

169169
return {
170-
fileUri: editor.document.uri.toString().substring(0, CodeWhispererConstants.filenameCharsLimit),
170+
fileUri: editor.document.uri.toString().split('?')[0].substring(0, CodeWhispererConstants.filenameCharsLimit),
171171
filename: getFileRelativePath(editor),
172172
programmingLanguage: {
173173
languageName: languageName,

0 commit comments

Comments
 (0)