Fix Completion bug with null string (#168)

This commit is contained in:
Laura Yu
2023-02-28 10:18:46 -08:00
committed by GitHub
parent 437a4151e4
commit b21c0e461d
3 changed files with 31 additions and 15 deletions
@@ -203,14 +203,15 @@ class TemplateReader {
);
// Duplicate
const upperKey = nextKey.value.toUpperCase();
if (upperKeys[upperKey]) {
this._context.error(nextKey, `'${nextKey.value}' is already defined`);
this.skipValue();
continue;
if (nextKey.value) {
const upperKey = nextKey.value.toUpperCase();
if (upperKeys[upperKey]) {
this._context.error(nextKey, `'${nextKey.value}' is already defined`);
this.skipValue();
continue;
}
upperKeys[upperKey] = true;
}
upperKeys[upperKey] = true;
// Well known
const nextPropertyDef = this._schema.matchPropertyAndFilter(mappingDefinitions, nextKey.value);
if (nextPropertyDef) {
@@ -339,13 +340,15 @@ class TemplateReader {
);
// Duplicate
const upperKey = nextKey.value.toUpperCase();
if (upperKeys[upperKey]) {
this._context.error(nextKey, `'${nextKey.value}' is already defined`);
this.skipValue();
continue;
if (nextKey.value) {
const upperKey = nextKey.value.toUpperCase();
if (upperKeys[upperKey]) {
this._context.error(nextKey, `'${nextKey.value}' is already defined`);
this.skipValue();
continue;
}
upperKeys[upperKey] = true;
}
upperKeys[upperKey] = true;
// Validate
this.validate(nextKey, keyDefinition);
@@ -443,7 +446,7 @@ class TemplateReader {
private parseScalar(token: LiteralToken, definitionInfo: DefinitionInfo): ScalarToken {
// Not a string
if (!isString(token)) {
if (!isString(token) || !token.value) {
return token;
}