fix(ansi): don't emit a blank line per nesting level after nested lists - #587
Open
larrasket wants to merge 1 commit into
Open
fix(ansi): don't emit a blank line per nesting level after nested lists#587larrasket wants to merge 1 commit into
larrasket wants to merge 1 commit into
Conversation
A nested list rendered as a BlockElement with Newline set, so it emitted a trailing blank line on finish. When a list ended in a nested sub-list, each stacked level added its own blank line, so the number of blank lines after the last item grew with the nesting depth. Suppress the trailing newline for a nested list that is the last item of its parent list item, so exactly one blank line follows the list regardless of nesting depth. Fixes charmbracelet#102
Member
|
Hi! Thanks for the contribution. Mind illustrating the problem you're having and how this PR fixes it? A short, human-authored explanation will go a long way. |
Author
|
when a list is in a nested sublist, one extra blank line is added per level of nesting before the content. for example two levels of nesting looks like this; it is not really annoying with a single sublist but it becomes much worse if you have more deep nested levels. This happens because a nested list is emitted as a block with a trailing newline. When a nested list is the last thing inside its parent list item, each of the rest of the levels adds its trailing newline. my fix suppresses that trailing newline when the list is the last item of its parent item.. |
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.
A nested list rendered as a BlockElement with Newline set, when a list ended in a nested sub-list, each stacked level added its own blank line, so the number of blank lines after the last item grew with the nesting depth. this suppress the trailing newline for a nested list that is the last item of its parent list item.
Fixes #102
CONTRIBUTING.md.