Repository navigation
Leave the pending indentation alone on an empty Write [patch] - #147
Merged
Merged
Conversation
Write("") and Write(null) reached IndentedTextWriter.Write, which writes
the pending tabs and clears its tabs-pending flag even for empty text.
A following NewLine() then left the tabs on the blank line and the next
line started at column 0. Write now returns early for empty input.
Fixes #126
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW3gZxmT7yZRzkmnHAX
|
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 #126
What changed
CodeBlocker.Writenow returns at once when the text is empty or null. Before this change, it passed the text on toIndentedTextWriter.Write, which writes the pending tabs and clears its tabs-pending flag even for an empty string. ANewLine()that followed left the tabs on the blank line, and every line after it in the scope started at column 0. This was the empty-input gap in the NewLine() after a partial Write() makes the next line lose its indentation (also breaks expression bodies that start with a blank line) #115 fix.<remarks>toWritedescribing the behaviour.Write(string)is the onlyWriteoverload, so no other overload needed the same check.Tests
CodeBlockerTests.NewLineAfterAnEmptyWriteKeepsTheNextLineIndented, run with""and withnull. It sits next to the NewLine() after a partial Write() makes the next line lose its indentation (also breaks expression bodies that start with a blank line) #115 regression test.Generated by Claude Code