Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: preserve line breaks from original input #412

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mcwarman
Copy link

Motivation

Preserve the line breaks from input.

We use this project as dependency in a project that round trips YAML, this attempts to try and preserve the formatting. It will only ever add one line break between lines regardless of input.

Changes

  • add checkLineBreak method that uses the previous token to calculate if there should be a line break
  • account for token.SequenceEntryType using the previous token of that.
  • ensure multiline strings are accounted for in the logic
  • add a new table test
  • update existing test to validate string output has changed
  • update existing tests to output differences on failure

Checks

  • Describe the purpose for which you created this PR.
  • Create test code that corresponds to the modification

@codecov-commenter
Copy link

Codecov Report

Merging #412 (bf7faf1) into master (0640a15) will not change coverage.
The diff coverage is n/a.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #412   +/-   ##
=======================================
  Coverage   76.02%   76.02%           
=======================================
  Files          13       13           
  Lines        4692     4692           
=======================================
  Hits         3567     3567           
  Misses        866      866           
  Partials      259      259           

@mcwarman
Copy link
Author

mcwarman commented Jan 2, 2024

@goccy I'd be interested to get your thoughts on this.

If you specifically have reservations/thoughts on how the change could be behind a feature flag for backwards compatibility, let me know.

lbc := "\n"
prev := t.Prev
var adjustment int
// if the previous type is sequence entry user the previous type for that
Copy link

Choose a reason for hiding this comment

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

Suggested change
// if the previous type is sequence entry user the previous type for that
// if the previous type is sequence entry use the previous type for that

@olblak
Copy link

olblak commented Apr 29, 2024

@goccy Kindly pinging you in cased you missed the previous notification.
It would be awesome to see this pullrequest moving forward

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.

None yet

4 participants