Skip to content

Commit 6829453

Browse files
committed
Remove annoying log output related to modelines
Currently, a log entry is emitted whenever a modeline comment is parsed. This is because, in #1193, the logic for how modelines were parsed was changed. On this line: https://github.com/redhat-developer/yaml-language-server/pull/1193/changes#diff-dc843f2ff5a3d197853464e616d6e413820becbc82e0e9a3aa6fc6d996976bb2L21 there is always 2 entries if a parsable modeline is present. This is because the index 0 entry contains the entire match, and the index 1 entry contains the group match (that contains the URI of the schema). This means that the `console.log()` will always run, incorrectly alerting the user that they tried to specify two schemas in the modeline. Even if the message were accurate, I don't think logging is the best way to alert the user to this problem. This should ideally be a warning or error instead. For now, I'm removing the `console.log()` entirely to address this. Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent d9f5349 commit 6829453

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/languageservice/services/modelineUtil.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@ export function getSchemaFromModeline(doc: SingleYAMLDocument | JSONDocument): s
1717
return isModeline(lineComment);
1818
});
1919
if (yamlLanguageServerModeline != undefined) {
20-
const schemaMatchs = yamlLanguageServerModeline.match(/\$schema(?:=|:\s*)(\S+)/);
21-
if (schemaMatchs !== null && schemaMatchs.length >= 1) {
22-
if (schemaMatchs.length >= 2) {
23-
console.log(
24-
'Several $schema attributes have been found on the yaml-language-server modeline. The first one will be picked.'
25-
);
26-
}
27-
return schemaMatchs[1];
20+
const schemaMatches = yamlLanguageServerModeline.match(/\$schema(?:=|:\s*)(\S+)/);
21+
if (schemaMatches !== null && schemaMatches.length >= 1) {
22+
return schemaMatches[1];
2823
}
2924
}
3025
}

0 commit comments

Comments
 (0)