fix(editor): support Unicode SQL completion prefixes

This commit is contained in:
t8y2 committed 2026-07-27 17:33:18 +08:00
1 parent 307985c8a2
commit d26c77ceb6
3 files changed
+91 -11

No files matched your search

+8 -7
View File
@@ -1721,6 +1721,8 @@ function isCallRoutineContext(beforeToken: string): boolean {
return /\bcall\s+(?:[A-Za-z_][\w$]*\.)?$/i.test(beforeToken) || /\bcall\s+(?:[A-Za-z_][\w$]*\.)?[A-Za-z_][\w$]*$/i.test(beforeToken);
}
const SQL_IDENTIFIER_START_CHAR = /[@_\p{ID_Start}]/u;
const SQL_IDENTIFIER_SUFFIX = /[$@_\u200c\u200d\p{ID_Continue}]+$/u;
const SQL_IDENTIFIER_CONTINUE_CHAR = /[$_\u200c\u200d\p{ID_Continue}]/u;
function hasTableAliasAfterCursor(sql: string, cursor: number): boolean {
@@ -2022,13 +2024,12 @@ function parseTrailingIdentifierPart(input: string, endExclusive: number): { sta
return null;
}
let start = end;
while (start >= 0 && /[A-Za-z0-9_$@]/.test(input[start] ?? "")) start -= 1;
start += 1;
if (start >= endExclusive) return null;
const raw = input.slice(start, endExclusive);
if (!/^[@A-Za-z_][\w$@]*$/.test(raw)) return null;
return { start, raw };
const match = SQL_IDENTIFIER_SUFFIX.exec(input.slice(0, endExclusive));
if (!match) return null;
const raw = match[0];
const firstCodePoint = raw.codePointAt(0);
if (firstCodePoint === undefined || !SQL_IDENTIFIER_START_CHAR.test(String.fromCodePoint(firstCodePoint))) return null;
return { start: match.index, raw };
}
/**