fix(editor): include fullwidth parens in completion depth

This commit is contained in:
Mo-Moore authored and GitHub committed 2026-09-23 16:30:07 +08:00
1 parent 391af14c75
commit 37a5413641
3 files changed
+49 -9

No files matched your search

+5 -4
View File
@@ -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;
}
+8 -5
View File
@@ -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;
}