fix(sql): correct table introducer keyword completion

This commit is contained in:
dadong authored and GitHub committed 2026-09-28 13:13:02 +08:00
1 parent 9e17d465a0
commit 8a3b8eed67
2 files changed
+28 -6

No files matched your search

+10 -6
View File
@@ -1010,12 +1010,11 @@ function buildCursorIntent(tokens: readonly SqlSemanticToken[], cursor: number,
};
}
// Same rule as the unqualified table slot below: the introducer is the word before the
// identifier being completed, never the identifier itself (issue #10415).
if (
trailing.qualifierParts.length > 0 &&
(previous === "from" ||
previous === "join" ||
TABLE_INTRODUCERS.has(previous) ||
TABLE_INTRODUCERS.has(wordBeforeReplacement) ||
(TABLE_INTRODUCERS.has(wordBeforeReplacement) ||
TABLE_INTRODUCERS.has(wordBeforeTrailing) ||
(!!targetSource && !targetSource.alias && trailing.replacementRange.start >= targetSource.sourceSpan.start && trailing.replacementRange.start <= targetSource.sourceSpan.end + 1 && TABLE_INTRODUCERS.has(wordBeforePosition(tokens, targetSource.sourceSpan.start))))
) {
@@ -1027,8 +1026,13 @@ function buildCursorIntent(tokens: readonly SqlSemanticToken[], cursor: number,
return { kind: "alias_column", prefix: trailing.prefix, replacementRange: trailing.replacementRange, qualifierParts: trailing.qualifierParts, targetSourceId: targetSource.id, expectedObjectKinds: ["column"], confidence: "high" };
}
if (TABLE_INTRODUCERS.has(previous) || TABLE_INTRODUCERS.has(wordBeforeReplacement) || TABLE_INTRODUCERS.has(wordBeforeTrailing) || previous === "from" || previous === "join" || wordBeforeReplacement === "from" || wordBeforeReplacement === "join" || tableListContinuation) {
return { kind: previous === "join" ? "table" : "table", prefix: trailing.prefix, replacementRange: trailing.replacementRange, qualifierParts: trailing.qualifierParts, expectedObjectKinds: ["table", "view"], confidence: "high" };
// A table introducer only introduces the slot that follows it, so both checks read
// the word before the identifier being completed (wordBeforeTrailing) or before its
// whole qualified name (wordBeforeReplacement). `previous` must not be used here: it
// is the word at the cursor, so typing `update`/`from`/`join` in full made the
// keyword introduce its own slot and dropped its own completion (issue #10415).
if (TABLE_INTRODUCERS.has(wordBeforeReplacement) || TABLE_INTRODUCERS.has(wordBeforeTrailing) || tableListContinuation) {
return { kind: "table", prefix: trailing.prefix, replacementRange: trailing.replacementRange, qualifierParts: trailing.qualifierParts, expectedObjectKinds: ["table", "view"], confidence: "high" };
}
if (previous === "call" || previous === "exec" || previous === "execute") {