From 5314fcbe25ae55980a0a745caa2117300eab62d1 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Fri, 8 Aug 2025 12:30:02 -0700 Subject: [PATCH] test: update test --- core/nextEdit/templating/model1.vitest.ts | 56 ++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/core/nextEdit/templating/model1.vitest.ts b/core/nextEdit/templating/model1.vitest.ts index 3facc6f6d..c2e603da0 100644 --- a/core/nextEdit/templating/model1.vitest.ts +++ b/core/nextEdit/templating/model1.vitest.ts @@ -94,12 +94,16 @@ line 1 line 2 line 3 line 4`; + const windowStart = 0; + const windowEnd = 4; const cursorPosition: Position = { line: 2, character: 4 }; const editableRegionStartLine = 1; const editableRegionEndLine = 3; const result = currentFileContentBlock( content, + windowStart, + windowEnd, editableRegionStartLine, editableRegionEndLine, cursorPosition, @@ -120,12 +124,16 @@ line 4`; const content = `line 0 line 1 line 2`; + const windowStart = 0; + const windowEnd = 2; const cursorPosition: Position = { line: 1, character: 0 }; const editableRegionStartLine = 0; const editableRegionEndLine = 2; const result = currentFileContentBlock( content, + windowStart, + windowEnd, editableRegionStartLine, editableRegionEndLine, cursorPosition, @@ -144,12 +152,16 @@ line 2 const content = `line 0 line 1 line 2`; + const windowStart = 0; + const windowEnd = 2; const cursorPosition: Position = { line: 1, character: 6 }; // end of "line 1" const editableRegionStartLine = 0; const editableRegionEndLine = 2; const result = currentFileContentBlock( content, + windowStart, + windowEnd, editableRegionStartLine, editableRegionEndLine, cursorPosition, @@ -168,12 +180,16 @@ line 2 const content = `line 0 line 1 line 2`; + const windowStart = 0; + const windowEnd = 2; const cursorPosition: Position = { line: 1, character: 2 }; const editableRegionStartLine = 1; const editableRegionEndLine = 1; const result = currentFileContentBlock( content, + windowStart, + windowEnd, editableRegionStartLine, editableRegionEndLine, cursorPosition, @@ -188,15 +204,19 @@ line 2`; expect(result).toBe(expected); }); - test("should handle cursor outside bounds gracefully", () => { + test("should handle cursor outside bounds gracefully (this shouldn't happen)", () => { const content = `line 0 line 1`; + const windowStart = 0; + const windowEnd = 1; const cursorPosition: Position = { line: 10, character: 0 }; // out of bounds const editableRegionStartLine = 0; const editableRegionEndLine = 1; const result = currentFileContentBlock( content, + windowStart, + windowEnd, editableRegionStartLine, editableRegionEndLine, cursorPosition, @@ -214,12 +234,16 @@ line 1 const content = `line 0 line 1 line 2`; + const windowStart = 0; + const windowEnd = 2; const cursorPosition: Position = { line: 1, character: 0 }; const editableRegionStartLine = 0; const editableRegionEndLine = 2; const result = currentFileContentBlock( content, + windowStart, + windowEnd, editableRegionStartLine, editableRegionEndLine, cursorPosition, @@ -233,6 +257,36 @@ line 2 expect(result).toBe(expected); }); + + test("should handle windowing - content outside window not included", () => { + const content = `line 0 +line 1 +line 2 +line 3 +line 4`; + const windowStart = 1; + const windowEnd = 3; + const cursorPosition: Position = { line: 2, character: 2 }; + const editableRegionStartLine = 2; + const editableRegionEndLine = 2; + + const result = currentFileContentBlock( + content, + windowStart, + windowEnd, + editableRegionStartLine, + editableRegionEndLine, + cursorPosition, + ); + + const expected = `line 1 +<|editable_region_start|> +li<|user_cursor_is_here|>ne 2 +<|editable_region_end|> +line 3`; + + expect(result).toBe(expected); + }); }); describe("editHistoryBlock", () => {