Skip to content

Commit 7b1f59a

Browse files
committed
nes: fix off by one
1 parent ac11cc4 commit 7b1f59a

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/extension/xtab/common/promptCrafting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ export function clipPreservingRange(
693693
);
694694

695695
const linesOffsetStart = firstPageIdx * pageSize;
696-
const linesOffsetEndExcl = lastPageIdx * pageSize + pageSize + 1 /* because excl */;
696+
const linesOffsetEndExcl = lastPageIdx * pageSize + pageSize;
697697

698698
return Result.ok(new OffsetRange(linesOffsetStart, linesOffsetEndExcl));
699699
}

src/extension/xtab/test/common/promptCrafting.spec.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,27 @@ suite('Paged clipping - current file', () => {
197197
10,
198198
{ ...opts, maxTokens: 20 },
199199
);
200-
assert(result.isError());
201-
expect(result.err).toMatchInlineSnapshot(`"outOfBudget"`);
200+
expect(result).toMatchInlineSnapshot(`
201+
ResultOk {
202+
"val": {
203+
"nLines": 6,
204+
"taggedCurrentFileContent": "21
205+
<area_around_code_to_edit>
206+
22
207+
23
208+
<code_to_edit>
209+
24
210+
25
211+
<code_to_edit>
212+
26
213+
</area_around_code_to_edit>
214+
27
215+
28
216+
29
217+
30",
218+
},
219+
}
220+
`);
202221
});
203222

204223

0 commit comments

Comments
 (0)