Skip to content

Commit c15744c

Browse files
committed
fix: test
1 parent fc89521 commit c15744c

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ ${itemLog}
395395

396396
const cursorPosition = document.validatePosition(position)
397397

398+
// Edit suggestion works differently than completion suggestion, so even when it's a deletion and cause cursor to move back, we still allow the request to go through
398399
if (position.isAfter(editor.selection.active) && items.length > 0 && !items[0].isInlineEdit) {
399400
const params: LogInlineCompletionSessionResultsParams = {
400401
sessionId: session.sessionId,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ export class RecommendationService {
6767
context: InlineCompletionContext,
6868
token: CancellationToken,
6969
isAutoTrigger: boolean,
70-
options: GetAllRecommendationsOptions = { emitTelemetry: true, showUi: true },
71-
documentEventListener: DocumentEventListener
70+
documentEventListener: DocumentEventListener,
71+
options: GetAllRecommendationsOptions = { emitTelemetry: true, showUi: true }
7272
) {
7373
const documentChangeEvent = documentEventListener?.getLastDocumentChangeEvent(document.uri.fsPath)?.event
7474

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { createMockDocument } from 'aws-core-vscode/test'
1414
import { CursorUpdateManager } from '../../../../../src/app/inline/cursorUpdateManager'
1515
import { CodeWhispererStatusBarManager } from 'aws-core-vscode/codewhisperer'
1616
import { globals } from 'aws-core-vscode/shared'
17+
import { DocumentEventListener } from '../../../../../src/app/inline/documentEventListener'
1718

1819
describe('RecommendationService', () => {
1920
let languageClient: LanguageClient
@@ -28,6 +29,10 @@ describe('RecommendationService', () => {
2829
const mockPosition = { line: 0, character: 0 } as Position
2930
const mockContext = { triggerKind: InlineCompletionTriggerKind.Automatic, selectedCompletionInfo: undefined }
3031
const mockToken = { isCancellationRequested: false } as CancellationToken
32+
const mockDocumentEventListener = {
33+
isLastEventDeletion: (filepath: string) => false,
34+
getLastDocumentChangeEvent: (filepath: string) => undefined,
35+
} as DocumentEventListener
3136
const mockInlineCompletionItemOne = {
3237
insertText: 'ItemOne',
3338
} as InlineCompletionItem
@@ -134,7 +139,8 @@ describe('RecommendationService', () => {
134139
mockPosition,
135140
mockContext,
136141
mockToken,
137-
true
142+
true,
143+
mockDocumentEventListener
138144
)
139145

140146
// Verify sendRequest was called with correct parameters
@@ -177,7 +183,8 @@ describe('RecommendationService', () => {
177183
mockPosition,
178184
mockContext,
179185
mockToken,
180-
true
186+
true,
187+
mockDocumentEventListener
181188
)
182189

183190
// Verify sendRequest was called with correct parameters
@@ -218,7 +225,8 @@ describe('RecommendationService', () => {
218225
mockPosition,
219226
mockContext,
220227
mockToken,
221-
true
228+
true,
229+
mockDocumentEventListener
222230
)
223231

224232
// Verify recordCompletionRequest was called
@@ -235,6 +243,7 @@ describe('RecommendationService', () => {
235243
mockContext,
236244
mockToken,
237245
true,
246+
mockDocumentEventListener,
238247
{
239248
showUi: false,
240249
emitTelemetry: true,
@@ -254,7 +263,8 @@ describe('RecommendationService', () => {
254263
mockPosition,
255264
mockContext,
256265
mockToken,
257-
true
266+
true,
267+
mockDocumentEventListener
258268
)
259269

260270
// Verify UI methods were called
@@ -286,6 +296,7 @@ describe('RecommendationService', () => {
286296
mockContext,
287297
mockToken,
288298
true,
299+
mockDocumentEventListener,
289300
options
290301
)
291302

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.121",
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",

0 commit comments

Comments
 (0)