Skip to content

Commit

Permalink
Also don't suggest different-case properties
Browse files Browse the repository at this point in the history
  • Loading branch information
winstliu committed Oct 1, 2024
1 parent 7ee5891 commit 1be2e57
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/languageservice/services/yamlCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1be2e57

Please sign in to comment.