Keep the next line indented when NewLine() ends a partial Write() [patch] - #116
Merged
Merged
Conversation
…tch] NewLine() wrote through IndentedTextWriter.WriteLineNoTabs, which does not re-arm the pending-tab flag, so after a partial Write() the next line came out at column zero. CodeBlocker now tracks whether a line is under way and ends it with WriteLine() in that case, keeping WriteLineNoTabs for blank lines so they stay free of whitespace. WriteExpressionBody also skips leading blank lines, as it already skips trailing ones, so the arrow is no longer left dangling with a trailing space at the end of the declaration line. Fixes #115 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018fKEEvMM2dQpZfMjTCXhRL
|
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 #115
What changed
CodeBlockernow tracks whether a line is under way. A non-emptyWritesets the flag, andWriteLine/NewLineclear it.NewLine()ends a line that is under way withIndentedTextWriter.WriteLine(). That call writes no tabs in that state and re-arms the indent for the next line. At the start of a line it still usesWriteLineNoTabs, so blank lines stay free of whitespace.WriteExpressionBodyskips leading blank lines, as it already skipped trailing ones.=>no longer dangles, with a trailing space, at the end of the declaration line.WriteConstraintsdescribed the oldNewLine()hazard, so it has been trimmed.Tests
NewLineAfterAPartialWriteKeepsTheNextLineIndentedis the core reproduction from the issue.NewLineAtTheStartOfALineStillWritesNoIndentationchecks that a blank line after a partial write stays unindented and that the line after it is indented.AnExpressionBodyStartingWithABlankLineKeepsItsFirstLineOnTheDeclarationis the template reproduction from the issue.With the library changes reverted, all three new tests fail. With them applied, the full suite passes, 185 of 185 on net10.0.
NewLineShouldAddEmptyLine,BlankLineUsesTheConfiguredTerminatorandAMultiLineExpressionBodyKeepsABlankLineWithoutIndentingItpass unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_018fKEEvMM2dQpZfMjTCXhRL
Generated by Claude Code