Skip to content

fix(encoder): skip indentation for top-level sequences#855

Open
nervo wants to merge 1 commit intogoccy:masterfrom
nervo:fix-top-level-sequence-indentation
Open

fix(encoder): skip indentation for top-level sequences#855
nervo wants to merge 1 commit intogoccy:masterfrom
nervo:fix-top-level-sequence-indentation

Conversation

@nervo
Copy link
Copy Markdown
Contributor

@nervo nervo commented Mar 15, 2026

When using encoder IndentSequence option, top level sequences are always indented, like i've already spotted in #291 (4 years ago, omg :) )
The playground is still available here https://go.dev/play/p/_mn80-HkPHK

Anyway, after digging into the code, i have found that indentation is handled differently for maps and sequences:

  • directly into encodeSlice/encodeArray for slices, using e.column, without any solution to check the top level
  • into encodeMapItem/encodeMap/encodeStruct for maps, by applying reverse logic, aka. considering that indentation is only appliable for embedded maps.

So i have just moved the sequence indentation logic at the just same level of maps, add some tests, and voila :)

Fix #291

@codecov-commenter
Copy link
Copy Markdown

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

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.49%. Comparing base (d4021ff) to head (5df9c7b).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #855      +/-   ##
==========================================
- Coverage   80.51%   80.49%   -0.03%     
==========================================
  Files          22       22              
  Lines        6847     6848       +1     
==========================================
- Hits         5513     5512       -1     
- Misses        913      914       +1     
- Partials      421      422       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Root sequences should not be indentend

2 participants