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): include fullwidth parens in completion depth
Mo-Moore37a5413641b8
diff --git a/apps/desktop/src/lib/sql/insertValueHints.ts b/apps/desktop/src/lib/sql/insertValueHints.tsindex 4762556993..6ac3f41fb0 100644--- a/apps/desktop/src/lib/sql/insertValueHints.ts+++ b/apps/desktop/src/lib/sql/insertValueHints.ts@@ -486,13 +486,14 @@ function stepLexState(sql: string, index: number, state: LexState, dialectId: st}return index + 1;}- if (ch === "(") {+ // Match tokenizeSqlSemantic: fullwidth () update nesting the same as ASCII ().+ if (ch === "(" || ch === "\uFF08") {state.depth += 1;- return index + 1;+ return index + ch.length;}- if (ch === ")") {+ if (ch === ")" || ch === "\uFF09") {state.depth = Math.max(0, state.depth - 1);- return index + 1;+ return index + ch.length;}return index + 1;}diff --git a/apps/desktop/src/lib/sql/semantic/tokens.ts b/apps/desktop/src/lib/sql/semantic/tokens.tsindex 2b759af593..1ee871bdee 100644--- a/apps/desktop/src/lib/sql/semantic/tokens.ts+++ b/apps/desktop/src/lib/sql/semantic/tokens.ts@@ -232,11 +232,14 @@ export function tokenizeSqlSemantic(input: string, dialectId = "mysql", options?continue;}- if ("(),.;*".includes(ch)) {- if (ch === ")") depth = Math.max(0, depth - 1);- tokens.push(token("punctuation", ch, start, start + 1, depth));- if (ch === "(") depth += 1;- index += 1;+ // Fullwidth () (U+FF08/U+FF09) are common IME typos in Chinese locales; treat them like+ // ASCII () for nesting depth so commas inside to_date(…, …) stay nested and do not split+ // INSERT ... SELECT projections (insert value column hints).+ if ("(),.;*".includes(ch) || ch === "\uFF08" || ch === "\uFF09") {+ if (ch === ")" || ch === "\uFF09") depth = Math.max(0, depth - 1);+ tokens.push(token("punctuation", ch, start, start + ch.length, depth));+ if (ch === "(" || ch === "\uFF08") depth += 1;+ index += ch.length;continue;}diff --git a/packages/app-tests/insertValueHints.test.ts b/packages/app-tests/insertValueHints.test.tsindex 25c99395ac..39c5d8da88 100644--- a/packages/app-tests/insertValueHints.test.ts+++ b/packages/app-tests/insertValueHints.test.ts@@ -279,6 +279,42 @@ test("keeps the hint for a projection whose alias names a different column", ());});+test("does not split nested to_date arguments into extra SELECT projections", () => {+ // ASCII parentheses: commas inside to_date(to_char(...), 'fmt') stay nested.+ const ascii = [+ "INSERT INTO t_demo (occur_date, company_no, company_name, dep_id, market_code)",+ "SELECT",+ " to_date(to_char(a.l_date), 'YYYYMMDD') as occur_date,",+ " '01694' as company_no,",+ " 'Acme Corp' as company_name,",+ " d.dept_code as dep_id,",+ " a.market_code",+ "FROM dual a, dual d",+ ].join("\n");+ assert.deepEqual(+ parseInsertValueHints(ascii).map((hint) => ({ column: hint.column, text: ascii.slice(hint.from).split(/[\s,]/u, 1)[0] })),+ [{ column: "market_code", text: "a.market_code" }],+ );++ // Fullwidth outer parentheses (common IME typo) must not treat the format-string comma as a+ // top-level projection separator — that shifted every later hint by one.+ const fullwidth = [+ "INSERT INTO t_demo (occur_date, company_no, company_name, dep_id, market_code)",+ "SELECT",+ " to_date\uFF08to_char(a.l_date), 'YYYYMMDD'\uFF09 as occur_date,",+ " '01694' as company_no,",+ " 'Acme Corp' as company_name,",+ " d.dept_code as dep_id,",+ " a.market_code",+ "FROM dual a, dual d",+ ].join("\n");+ assert.equal(parseInsertValuesClauses(fullwidth)[0]?.rows[0]?.length, 5);+ assert.deepEqual(+ parseInsertValueHints(fullwidth).map((hint) => ({ column: hint.column, text: fullwidth.slice(hint.from).split(/[\s,]/u, 1)[0] })),+ [{ column: "market_code", text: "a.market_code" }],+ );+});+test("caps INSERT ... SELECT hints to the smaller target or projection count", () => {assert.deepEqual(parseInsertValueHints("INSERT INTO t (a, b) SELECT x, y, z FROM source").map((hint) => hint.column),