7 files changed
+117
-41
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { currentStatementFrameRangeTo, estimateInlineHintVisualColumns, isWideSqlChar, visualSqlColumns, visualSqlColumnsWithInlineHints } from "@/lib/sql/currentStatementFrame";
|
||||
import { currentStatementFrameRangeTo, estimateInlineHintVisualColumns, isWideSqlChar, shouldRebuildCurrentStatementFrame, visualSqlColumns, visualSqlColumnsWithInlineHints } from "@/lib/sql/currentStatementFrame";
|
||||
import type { SqlTextRange } from "@/lib/sql/sqlStatementRanges";
|
||||
|
||||
describe("currentStatementFrameRangeTo", () => {
|
||||
@@ -14,6 +14,18 @@ describe("currentStatementFrameRangeTo", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldRebuildCurrentStatementFrame", () => {
|
||||
it("reuses frame decorations for pure viewport updates", () => {
|
||||
expect(shouldRebuildCurrentStatementFrame({ docChanged: false, selectionSet: false, configurationChanged: false })).toBe(false);
|
||||
});
|
||||
|
||||
it("rebuilds after document, selection, or configuration updates", () => {
|
||||
expect(shouldRebuildCurrentStatementFrame({ docChanged: true, selectionSet: false, configurationChanged: false })).toBe(true);
|
||||
expect(shouldRebuildCurrentStatementFrame({ docChanged: false, selectionSet: true, configurationChanged: false })).toBe(true);
|
||||
expect(shouldRebuildCurrentStatementFrame({ docChanged: false, selectionSet: false, configurationChanged: true })).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("visualSqlColumns", () => {
|
||||
it("counts ASCII as one column, tabs as four, and CJK/fullwidth characters as two", () => {
|
||||
expect(visualSqlColumns("A\t中B")).toBe(1 + 4 + 2 + 2);
|
||||
|
||||
@@ -346,6 +346,24 @@ describe("splitSqlStatementRanges", () => {
|
||||
expect(rangeSqlTexts(splitSqlStatementRanges(oracleIssue2405PlSql, "oracle"))).toEqual([oracleIssue2405PlSql]);
|
||||
});
|
||||
|
||||
it("splits large Dameng package bodies without repeated prefix parsing", () => {
|
||||
const body = Array.from({ length: 3000 }, (_, index) => ` v_value := v_value + ${index % 10};`).join("\n");
|
||||
const packageBody = `CREATE OR REPLACE PACKAGE BODY app.big_pkg AS
|
||||
PROCEDURE run IS
|
||||
v_value NUMBER := 0;
|
||||
BEGIN
|
||||
${body}
|
||||
END run;
|
||||
END big_pkg;`;
|
||||
const sql = `${packageBody}\n/\nSELECT 1;`;
|
||||
const startedAt = performance.now();
|
||||
const ranges = splitSqlStatementRanges(sql, "dameng");
|
||||
const elapsedMs = performance.now() - startedAt;
|
||||
|
||||
expect(rangeSqlTexts(ranges)).toEqual([packageBody, "SELECT 1"]);
|
||||
expect(elapsedMs).toBeLessThan(1000);
|
||||
});
|
||||
|
||||
it("keeps nested GaussDB procedure blocks together", () => {
|
||||
expect(rangeSqlTexts(splitSqlStatementRanges(gaussDbNestedProcedure, "gaussdb"))).toEqual([gaussDbNestedProcedure]);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user