fix(sql): keep EOF cursor on trailing statement

This commit is contained in:
t8y2 committed 2026-08-01 13:27:33 +08:00
1 parent 3bd194679d
commit 288cc0687a
2 files changed
+10 -2

No files matched your search

@@ -1101,6 +1101,12 @@ describe("buildExecutionCandidates", () => {
expect(candidateSummaries(candidates)).toEqual(["cursor:select 1", "all:select 1;\n\nselect 2;"]);
});
it("uses the final soft statement when the cursor follows trailing EOF whitespace", () => {
const sql = "SELECT 1\nSELECT 2 ";
const candidates = buildExecutionCandidates(sql, sql.length);
expect(candidateSummaries(candidates)).toEqual(["cursor:SELECT 2", "all:SELECT 1\nSELECT 2"]);
});
it("dedupes when the cursor statement equals the full document", () => {
const sql = "SELECT 1;";
const candidates = buildExecutionCandidates(sql, indexOf(sql, "1"));