From 1be2e57f79d42bc26bbab6f35cd50d7709b0d6a1 Mon Sep 17 00:00:00 2001 From: Winston Liu Date: Mon, 30 Sep 2024 20:51:07 -0700 Subject: [PATCH] Also don't suggest different-case properties --- src/languageservice/services/yamlCompletion.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/languageservice/services/yamlCompletion.ts b/src/languageservice/services/yamlCompletion.ts index 08182fa..650315c 100644 --- a/src/languageservice/services/yamlCompletion.ts +++ b/src/languageservice/services/yamlCompletion.ts @@ -691,8 +691,17 @@ export class YamlCompletion { }); } - const hasMatchingAlias = (propSchema: JSONSchema): boolean => { + const hasMatchingProperty = (key: string, propSchema: JSONSchema): boolean => { return node.items.some((pair) => { + if (!isScalar(pair.key) || typeof pair.key.value !== 'string') { + return false; + } + + const ignoreCase = shouldIgnoreCase(propSchema, 'key'); + if (ignoreCase && pair.key.value.toUpperCase() === key.toUpperCase() && pair.key.value !== key) { + return true; + } + if (Array.isArray(propSchema.aliases)) { return propSchema.aliases.some((alias) => { if (!isScalar(pair.key) || typeof pair.key.value !== 'string') { @@ -749,7 +758,7 @@ export class YamlCompletion { typeof propertySchema === 'object' && !propertySchema.deprecationMessage && !propertySchema['doNotSuggest'] && - !hasMatchingAlias(propertySchema) + !hasMatchingProperty(key, propertySchema) ) { let identCompensation = ''; if (nodeParent && isSeq(nodeParent) && node.items.length <= 1 && !hasOnlyWhitespace) {