fix(sql): keep EOF cursor on trailing statement
This commit is contained in:
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"));
|
||||
|
||||
@@ -585,8 +585,10 @@ export function statementRangeAtCursor(sql: string, cursorPos: number, databaseT
|
||||
return rangeForCursorInSoftRanges(sql, softRanges, pos) ?? rangeFor(statement, sql);
|
||||
}
|
||||
|
||||
if (pos > statement.to && (!next || pos < next.hitFrom) && isCursorOnStatementLine(sql, pos, statement)) {
|
||||
return rangeForCursorInSoftRanges(sql, softRanges, pos) ?? rangeFor(statement, sql);
|
||||
if (pos > statement.to && (!next || pos < next.hitFrom)) {
|
||||
const softRange = rangeForCursorInSoftRanges(sql, softRanges, pos);
|
||||
if (softRange) return softRange;
|
||||
if (isCursorOnStatementLine(sql, pos, statement)) return rangeFor(statement, sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user