Skip to content

feat(format/yaml): block scalar trailing comment lines - #11058

Merged
dyc3 merged 5 commits into
dyc3/yaml-fmt-document-breaksfrom
dyc3/yaml-fmt-block-scalar-comments
Jul 29, 2026
Merged

feat(format/yaml): block scalar trailing comment lines#11058
dyc3 merged 5 commits into
dyc3/yaml-fmt-document-breaksfrom
dyc3/yaml-fmt-block-scalar-comments

Conversation

@dyc3

@dyc3 dyc3 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

More comment handling in block scalars, and removes the last verbatim formatting call.

I'll let the clanker explain

A non-empty line indented less than the base ends a block scalar per
the spec, but the lexer includes such lines (trailing comments, in
practice) in the content token, and the formatter fell back to
verbatim. The content now ends at the first such line; the blank
lines the chomping dropped and the comment lines after them print after the scalar, dedented to the document root:

        strip: |-
          # text

        # comment

Whitespace-only lines at or below the base indentation now count as
empty for chomping. This removes the last verbatim fallback.

implemented by fable 5

Test Plan

updated snapshots

Docs

@github-actions

Copy link
Copy Markdown
Contributor

✅ Organic activity

No automation signals detected in the analyzed events.

View full analysis →

This is an automated analysis by AgentScan

@changeset-bot

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: bfa9baa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added A-Formatter Area: formatter L-Yaml Language: Yaml labels Jul 23, 2026
@dyc3
dyc3 marked this pull request as draft July 23, 2026 20:51
@dyc3
dyc3 force-pushed the dyc3/yaml-fmt-block-scalar-comments branch from 52c96b8 to 8cd0aca Compare July 27, 2026 11:58
@dyc3
dyc3 force-pushed the dyc3/yaml-fmt-block-scalar-comments branch from 8cd0aca to 18b4ce8 Compare July 28, 2026 20:19
@dyc3
dyc3 marked this pull request as ready for review July 28, 2026 22:40

@ematipico ematipico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comments here are like hell :D

dyc3 and others added 5 commits July 29, 2026 08:07
A non-empty line indented less than the base ends a block scalar per
the spec, but the lexer includes such lines (trailing comments, in
practice) in the content token, and the formatter fell back to
verbatim. The content now ends at the first such line; the blank
lines the chomping dropped and the comment lines after them print
after the scalar, dedented to the document root:

    strip: |-
      # text

    # comment

Whitespace-only lines at or below the base indentation now count as
empty for chomping. This removes the last verbatim fallback; the now
unused verbatim helper stays as dead code because the rules that
`just gen-formatter` generates for new syntax nodes call it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01472YxeN6U2t4LWfaqkieAv
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017JxH5Z1zv28qj1CcHABVee
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017JxH5Z1zv28qj1CcHABVee
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017JxH5Z1zv28qj1CcHABVee
@dyc3
dyc3 force-pushed the dyc3/yaml-fmt-block-scalar-comments branch from 18b4ce8 to bfa9baa Compare July 29, 2026 12:38
@dyc3
dyc3 merged commit a882bd9 into main Jul 29, 2026
27 checks passed
@dyc3
dyc3 deleted the dyc3/yaml-fmt-block-scalar-comments branch July 29, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter L-Yaml Language: Yaml

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants