Skip to content

Fix: ignore modeline schema comment in the middle of file after yaml content#1288

Merged
datho7561 merged 1 commit into
redhat-developer:mainfrom
shin19991207:fix-1260
Jun 29, 2026
Merged

Fix: ignore modeline schema comment in the middle of file after yaml content#1288
datho7561 merged 1 commit into
redhat-developer:mainfrom
shin19991207:fix-1260

Conversation

@shin19991207

Copy link
Copy Markdown
Member

What does this PR do?

Modeline schema comment should only be supported in the document header comment.

Ignore modeline schema comment if it is in the middle of file after yaml content, e.g.

foo:
  bar
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
aa:bbb

or

foo:
  bar
# $schema=https://json-schema.org/draft-07/schema#
aa:bbb

Modeline schema comment in multiline comments at document header is still handled, e.g.

# foo:
#   bar
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
aa:bbb

What issues does this PR fix or reference?

Fixes redhat-developer/vscode-yaml#1260

Is it tested? How?

  • New automated tests
  • Tested manaully

Signed-off-by: Morgan Chang <shin19991207@gmail.com>
@shin19991207 shin19991207 requested a review from datho7561 as a code owner June 26, 2026 15:28

@datho7561 datho7561 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me and works from my testing. Thanks, Morgan!

@datho7561 datho7561 merged commit 416ede2 into redhat-developer:main Jun 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Commented out $schema field triggers schema loading error (yaml-language-server parsed commented lines)

2 participants