fix(completion): preserve longer keyword prefixes
This commit is contained in:
2 files changed
+42
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user