Skip to content

Preserve final line breaks when trimming whitespace - #330

Open
rksharma-owg wants to merge 1 commit into
google:mainfrom
rksharma-owg:codex/preserve-scalar-newline
Open

rksharma-owg wants to merge 1 commit into
google:mainfrom
rksharma-owg:codex/preserve-scalar-newline

Conversation

@rksharma-owg

Copy link
Copy Markdown

Fixes #261.

With trim_trailing_whitespace=true, the line scanner drops the terminal line break before YAML decoding. A final | or > scalar therefore loses its trailing newline, even with eof_newline=true.

Preserve the terminal LF or bare CR when rebuilding the trimmed input. Unterminated scalars keep their existing value. Regression tests compare parsed values across chomping modes and line endings at the trimming boundary, and exercise the reported cases through the formatter with EOF options and repeated formatting.

Validation:

  • Regressions fail on the original implementation and pass with the fix.
  • Local go mod tidy, make vet, make test_v, make integrationtest, and make addlicense_check passed.
  • Fork preflight passed all seven jobs for a8912ab52cb252c270c971bbc7b55147c987b7cb against dea0b791be9796b82c2e7cf6864cb7dc36023d0b: baseline and patch checks with upstream automatic toolchain selection, explicit Go 1.23/1.24/1.25 compatibility checks, and license headers. Test caches were cleared between baseline and patch execution.

The existing folded-scalar emitter defect tracked in #313/#322 remains separate. >+ is covered at the trimming boundary; the YAML emitter is unchanged.

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

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.

Last label: | reformatted into label: |- despite new line

1 participant