Keep a CRLF split across two reads as one line break - #86
Merged
Merged
Conversation
LineOutputHandler normalized line endings per chunk, so a chunk ending in CR followed by one starting with LF became two line breaks and raised a spurious empty line. Recognize line endings on the buffered text instead, and hold a trailing CR back until the next chunk shows whether an LF follows. Fixes #85 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CGpRxGxuvhstHo5zXQoWSA
… body Also use the MSTest assertions the analyzer suggests in the new tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CGpRxGxuvhstHo5zXQoWSA
|
This was referenced Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #85
What changed
LineOutputHandler.ProcessDataByLineused to callReplaceLineEndings()on each incoming chunk. When a read boundary fell between\rand\n, one CRLF turned into two line breaks, and the handler raised an extra empty line.The handler now appends the raw chunk to the buffer and finds line endings in the buffered text:
ReplaceLineEndingsrecognizes. A lone CR still splits, as it did before.Tests
HandleStandardOutputDataShouldTreatCrlfSplitAcrossChunksAsOneLineBreakand its stderr twin feed"x\r"and then"\ny\n", and expect the linesxandy.HandleStandardOutputDataShouldHoldBackTrailingCarriageReturnchecks that the trailing CR stays buffered.HandleStandardOutputDataShouldSplitOnEveryLineEndingKindchecks that mixed CRLF, CR and LF input splits the same way it did before.With the fix temporarily reverted, the first three tests fail. With the fix in place, the full suite passes on Linux/net10.0: 45 passed, 2 skipped (the elevation tests that are Windows-only).
🤖 Generated with Claude Code
https://claude.ai/code/session_01CGpRxGxuvhstHo5zXQoWSA
Generated by Claude Code