25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(editor): skip statement frame for oversized oracle package bodies
Melody Ruch1e9babca458a
diff --git a/apps/desktop/src/lib/__tests__/editor/currentStatementFrameLayer.spec.ts b/apps/desktop/src/lib/__tests__/editor/currentStatementFrameLayer.spec.tsindex be94396f07..f6675200dc 100644--- a/apps/desktop/src/lib/__tests__/editor/currentStatementFrameLayer.spec.ts+++ b/apps/desktop/src/lib/__tests__/editor/currentStatementFrameLayer.spec.ts@@ -1,6 +1,6 @@import { describe, expect, it, vi } from "vitest";import { Text } from "@codemirror/state";-import { currentStatementFrameLayer, currentStatementFrameRect, FRAME_INSET_PX } from "@/lib/editor/codemirrorCurrentStatementFrameLayer";+import { currentStatementFrameLayer, currentStatementFrameRect, FRAME_INSET_PX, MAX_FRAME_STATEMENT_LINES } from "@/lib/editor/codemirrorCurrentStatementFrameLayer";interface CoordRect {left: number;@@ -252,6 +252,30 @@ describe("currentStatementFrameRect", () => {const expectedHeight = (73 - 47) * LINE_HEIGHT + FRAME_INSET_PX * 2;expect(rect!.height).toBe(expectedHeight);});++ it("skips huge multi-thousand-line statements instead of probing every line (dbx#7226)", () => {+ // A large Oracle package body is parsed as one statement spanning the+ // whole file. Without a cap, this loop would issue two coordsAtPos+ // calls per logical line, freezing the UI on every scroll frame.+ const lineCount = MAX_FRAME_STATEMENT_LINES + 2000;+ const lines = Array.from({ length: lineCount }, (_, i) => ` proc_body_line_${i};`);+ const view = buildView(lines);+ const coords = vi.spyOn(view, "coordsAtPos");++ const rect = currentStatementFrameRect(view, 0, view.state.doc.length);++ expect(rect).toBeNull();+ expect(coords).not.toHaveBeenCalled();+ });++ it("still frames a statement right at the line-count cap", () => {+ const lines = Array.from({ length: MAX_FRAME_STATEMENT_LINES + 1 }, (_, i) => `-- line ${i}`);+ const view = buildView(lines);++ const rect = currentStatementFrameRect(view, 0, view.state.doc.length);++ expect(rect).not.toBeNull();+ });});describe("currentStatementFrameLayer", () => {diff --git a/apps/desktop/src/lib/editor/codemirrorCurrentStatementFrameLayer.ts b/apps/desktop/src/lib/editor/codemirrorCurrentStatementFrameLayer.tsindex 41768baec6..4d45080670 100644--- a/apps/desktop/src/lib/editor/codemirrorCurrentStatementFrameLayer.ts+++ b/apps/desktop/src/lib/editor/codemirrorCurrentStatementFrameLayer.ts@@ -36,6 +36,17 @@ function spansVisualRows(start: PositionRect, end: PositionRect): boolean {return Math.abs(startMid - endMid) > Math.max(2, Math.min(startHeight, endHeight) / 2);}+/**+ * Statements spanning more logical lines than this render no frame. The+ * horizontal-bounds loop below does a constant number of geometry probes+ * per logical line, so its cost is O(logical lines) — fine for ordinary+ * statements, but a multi-thousand-line PL/SQL package body (Oracle, and+ * other dialects with BEGIN/END routine bodies) is parsed as a single+ * statement spanning the whole file, turning routine scrolling into+ * thousands of `coordsAtPos` calls per frame. See dbx#7226.+ */+export const MAX_FRAME_STATEMENT_LINES = 500;+/*** Measure the pixel rectangle of one statement rendered in `view`.*@@ -62,6 +73,7 @@ export function currentStatementFrameRect(view: Viewish, from: number, to: numbeconst startLine = doc.lineAt(from);const endLine = doc.lineAt(to);+ if (endLine.number - startLine.number > MAX_FRAME_STATEMENT_LINES) return null;const base = view.scrollDOM.getBoundingClientRect();// Vertical bounds: convert screen coords to content-layer coords.