fix(completion): preserve longer keyword prefixes

This commit is contained in:
zipg authored and GitHub committed 2026-07-21 17:14:01 +08:00
1 parent a12f8d09b7
commit 51f163ee6c
2 files changed
+42

No files matched your search

+14
View File
@@ -1393,6 +1393,8 @@ class SqlCompletionProvider {
if (context.suggestKeywords && !context.exclusiveRoutineSuggestions && !pendingJoinKeyword) {
this.items.push(...buildJoinModifierKeywordItems(context.prefix, this.input.keywordCase));
this.items.push(...buildKeywordItems(context.prefix, context, this.databaseType, this.input.keywordCase));
} else if (shouldOfferKeywordPrefixContinuations(context, pendingJoinKeyword)) {
this.items.push(...buildKeywordPrefixContinuationItems(context.prefix, context, this.databaseType, this.input.keywordCase));
}
if (!context.exclusiveTableSuggestions && context.suggestColumns) {
@@ -4147,6 +4149,18 @@ function buildKeywordItems(prefix: string, context: SqlCompletionContext, databa
});
}
function shouldOfferKeywordPrefixContinuations(context: SqlCompletionContext, pendingJoinKeyword: boolean): boolean {
return !!context.prefix && !pendingJoinKeyword && !context.qualifier && !context.exclusiveTableSuggestions && !context.exclusiveColumnSuggestions;
}
function buildKeywordPrefixContinuationItems(prefix: string, context: SqlCompletionContext, databaseType?: DatabaseType, keywordCase?: SqlKeywordCase): SqlCompletionItem[] {
const normalizedPrefix = prefix.toLowerCase();
return buildKeywordItems(prefix, context, databaseType, keywordCase).filter((item) => {
const normalizedLabel = item.label.toLowerCase();
return normalizedLabel.length > normalizedPrefix.length && normalizedLabel.startsWith(normalizedPrefix);
});
}
function matchesPrefix(candidate: string, prefix: string): boolean {
if (!prefix) return true;
return computeMatchScore(candidate, prefix) >= 0;