Skip to content

Remove annoying log output related to modelines#1212

Merged
datho7561 merged 1 commit intoredhat-developer:mainfrom
datho7561:dont-consolelog-about-modeline
Mar 12, 2026
Merged

Remove annoying log output related to modelines#1212
datho7561 merged 1 commit intoredhat-developer:mainfrom
datho7561:dont-consolelog-about-modeline

Conversation

@datho7561
Copy link
Copy Markdown
Contributor

What does this PR do?

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.

What issues does this PR fix or reference?

Fixes #1211

Is it tested? How?

Manually

@datho7561 datho7561 force-pushed the dont-consolelog-about-modeline branch from 6829453 to 0a1bcaf Compare March 12, 2026 20:03
Currently, a log entry is emitted whenever a modeline comment is parsed.
This is because, in
redhat-developer#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>
@datho7561 datho7561 force-pushed the dont-consolelog-about-modeline branch from 0a1bcaf to 05d23b4 Compare March 12, 2026 20:10
Copy link
Copy Markdown
Member

@shin19991207 shin19991207 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and fixes the issue. Thanks, David!

@datho7561 datho7561 merged commit 37a7b17 into redhat-developer:main Mar 12, 2026
4 checks passed
@datho7561 datho7561 deleted the dont-consolelog-about-modeline branch March 12, 2026 21:17
@datho7561 datho7561 added this to the 1.22.0 milestone Apr 16, 2026
@datho7561 datho7561 added the bug label Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

2 participants