diff --git a/src/features/lightspeed/utils/multiLinePromptForMultiTasks.ts b/src/features/lightspeed/utils/multiLinePromptForMultiTasks.ts index 03029309c..2e223688e 100644 --- a/src/features/lightspeed/utils/multiLinePromptForMultiTasks.ts +++ b/src/features/lightspeed/utils/multiLinePromptForMultiTasks.ts @@ -2,9 +2,9 @@ export function shouldRequestForPromptPosition( documentContent: string, promptLine: number, ): boolean { - const documentLines = documentContent.trim().split("\n"); + const documentLines = documentContent.split("\n").map((l) => l.trim()); if (documentLines.length > 0 && promptLine > 0) { - const promptLineText = documentLines[promptLine - 1].trim(); + const promptLineText = documentLines[promptLine - 1]; if (promptLineText.startsWith("# ") && promptLineText.endsWith(" &")) { // should do not make request for prompt that ends with "&" return false; diff --git a/test/units/lightspeed/utils/multiLinePromptForMultiTasks.test.ts b/test/units/lightspeed/utils/multiLinePromptForMultiTasks.test.ts index fbe28ea76..5af1f67ae 100644 --- a/test/units/lightspeed/utils/multiLinePromptForMultiTasks.test.ts +++ b/test/units/lightspeed/utils/multiLinePromptForMultiTasks.test.ts @@ -103,6 +103,15 @@ tasks: }); describe("Test shouldRequestForPromptPosition", () => { + it("should trigger request even when document starts with empty line", () => { + const promptContent = ` +--- +# Create a key-pair called lightspeed-key-pair & +# create a vpc & create vpc_id var `; + const shouldRequest = shouldRequestForPromptPosition(promptContent, 4); + assert.equal(shouldRequest, true); + }); + it("should not make request when prompt line start with '# ' and end with ' &' for tasks", () => { const promptContent = `--- # Create a key-pair called lightspeed-key-pair &