Repository navigation
Add WriteLines to write multi-line text at the current indent [minor] - #181
Merged
Merged
Conversation
WriteLine and Write hand their text straight to IndentedTextWriter, which indents only the first line, so every line after an embedded break landed at column 0. WriteLines splits at CRLF, LF and CR, writes each line at the current indent ending with NewLineString, keeps blank lines free of indentation, leaves the last line open when the text has no trailing break, and leaves line breaks inside a verbatim string literal as written. Fixes #179 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5MyZsxEdt96yVWhKn
|
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 #179
What changed
WriteLine(string)andWrite(string)pass their text straight toIndentedTextWriter, which indents only the first line. As the issue suggests, they stay as they are, and a new public method,CodeBlocker.WriteLines(string fragment), does the following:\r\n,\nand\r, and writes each line at the current indent, ending it withNewLineString. An LF writer never ends up with mixed line endings.NewLine(), so they carry no indentation.@"...",$@"...") exactly as written. It uses the sameVerbatimStringScannerasSplitLines, so the literal's value never changes.Write, soisMidLinematches how the text ends. When it is called mid-line, the first segment finishes the line already under way.nullor"".It does not reuse
SpliceFragmentdirectly, becauseSplitLinessplits only atNewLineString. With an LF writer, CRLF input would keep its\r.README's API table and CLAUDE.md now list the method.
Tests
WriteLinesTestsadds 8 cases:→\r\nand\rinput on an LF writer@"..."literal containing\r\nnull/empty (two cases)With
WriteLinesreduced toWrite(fragment), the 6 behavioural tests fail. The null/empty cases pass either way by design. With the change, the full suite passes: 257/257.Generated by Claude Code