Skip to content

fix: terminate margin background on each line#711

Open
c-tonneslan wants to merge 1 commit into
charmbracelet:mainfrom
c-tonneslan:fix-margin-background-reset
Open

fix: terminate margin background on each line#711
c-tonneslan wants to merge 1 commit into
charmbracelet:mainfrom
c-tonneslan:fix-margin-background-reset

Conversation

@c-tonneslan

Copy link
Copy Markdown

With MarginBackground, the SGR reset landed on the wrong side of the newline: on the top margin the [0m reset appeared at the start of the following line instead of the end of the margin line, and the bottom margin line was left uncolored (#115).

applyMargins styled the whole spaces\n… block in one call, so Styled placed the reset after the trailing newline. This styles each margin line on its own so the reset terminates the line before its newline.

NewStyle().MarginBackground(Color("9")).Margin(1, 0).Render("hi"):

- "\x1b[101m  \n\x1b[mhi\x1b[101m\n  \x1b[m"
+ "\x1b[101m  \x1b[m\nhi\n\x1b[101m  \x1b[m"

Added a regression test; the full suite passes.

Fixes #115

Style each top/bottom margin line individually so the background reset
lands before the newline instead of the next line's start, and color the
bottom margin line. Fixes charmbracelet#115.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Margin background color spills into the end of the line in the top and bottom right corners

1 participant