diff --git a/server/aws-lsp-codewhisperer/src/language-server/inline-completion/contants/constants.ts b/server/aws-lsp-codewhisperer/src/language-server/inline-completion/contants/constants.ts index 8cab372053..12455e84f3 100644 --- a/server/aws-lsp-codewhisperer/src/language-server/inline-completion/contants/constants.ts +++ b/server/aws-lsp-codewhisperer/src/language-server/inline-completion/contants/constants.ts @@ -1,6 +1,7 @@ export const FILE_URI_CHARS_LIMIT = 1024 export const FILENAME_CHARS_LIMIT = 1024 export const CONTEXT_CHARACTERS_LIMIT = 10240 +export const TEXTDOCUMENT_CHARS_LIMIT = 40000 export const EMPTY_RESULT = { sessionId: '', items: [] } export const EDIT_DEBOUNCE_INTERVAL_MS = 500 // ABAP ADT extensions commonly used with Eclipse diff --git a/server/aws-lsp-codewhisperer/src/language-server/inline-completion/handler/editCompletionHandler.ts b/server/aws-lsp-codewhisperer/src/language-server/inline-completion/handler/editCompletionHandler.ts index 2ea75f00dc..bdd70a525a 100644 --- a/server/aws-lsp-codewhisperer/src/language-server/inline-completion/handler/editCompletionHandler.ts +++ b/server/aws-lsp-codewhisperer/src/language-server/inline-completion/handler/editCompletionHandler.ts @@ -36,7 +36,7 @@ import { RejectedEditTracker } from '../tracker/rejectedEditTracker' import { getErrorMessage, hasConnectionExpired } from '../../../shared/utils' import { AmazonQError, AmazonQServiceConnectionExpiredError } from '../../../shared/amazonQServiceManager/errors' import { DocumentChangedListener } from '../documentChangedListener' -import { EMPTY_RESULT, EDIT_DEBOUNCE_INTERVAL_MS } from '../contants/constants' +import { EMPTY_RESULT, EDIT_DEBOUNCE_INTERVAL_MS, TEXTDOCUMENT_CHARS_LIMIT } from '../contants/constants' import { StreakTracker } from '../tracker/streakTracker' import { processEditSuggestion } from '../utils/diffUtils' @@ -256,7 +256,8 @@ export class EditCompletionHandler { programmingLanguage: { languageName: generateCompletionReq.fileContext?.programmingLanguage?.languageName, }, - text: textDocument.getText(), + // Naive truncation, maybe we need "40000" characters around current curosr position instead + text: textDocument.getText().substring(0, TEXTDOCUMENT_CHARS_LIMIT), }, cursorState: { position: {