Skip to content

Fix for parsing comments in flow mode#814

Open
joshuapare wants to merge 4 commits intogoccy:masterfrom
joshuapare:comment-fixes
Open

Fix for parsing comments in flow mode#814
joshuapare wants to merge 4 commits intogoccy:masterfrom
joshuapare:comment-fixes

Conversation

@joshuapare
Copy link
Copy Markdown

@joshuapare joshuapare commented Nov 10, 2025

Fixes issue #608 where comments in flow-style YAML (using [] and {}) were not being captured by CommentToMap.

This PR fixes the following behavior:

  • comments on closing tokens weren't being stored as FootComments on the AST nodes
  • decoder wasn't processing entry-level comments in flow-style sequences
  • comma-line comments in flow blocks were incorrectly assigned to the next element instead of the element before the comma (e.g., the comment after a, should belong to element at comma[0], not element b at comma[1])

For example:

flow_seq: [a, b, c]  # was captured
flow_map: {x: 1, y: 2}  # was captured
comma: [a, # was NOT captured
        b, # was NOT captured
        c] # was NOT captured
nested: {
  key: [1, 2]  # was NOT captured
}  # was NOT captured
empty: []  # was NOT captured
single: [x]  # was NOT captured
nested_seq: [[a, # was captured but DUPLICATED on element b 
              b], # was captured on WRONG element (outer entry instead of inner FootComment) 
              c] # was NOT captured on element c
mixed: {
  list: [1, 2], # was captured
  map: {x: y} # comment was captured BUT also leaked to $.mixed.map.x
}

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 10, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 70.21277% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.40%. Comparing base (b0ab069) to head (eb5a563).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #814      +/-   ##
==========================================
- Coverage   80.48%   80.40%   -0.09%     
==========================================
  Files          22       22              
  Lines        6845     6919      +74     
==========================================
+ Hits         5509     5563      +54     
- Misses        914      930      +16     
- Partials      422      426       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joshuapare joshuapare changed the title fixup for parsing comments in flow mode Fix for parsing comments in flow mode Nov 10, 2025
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.

2 participants