Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: render right margin for block stack elements #334

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

jahvon
Copy link
Contributor

@jahvon jahvon commented Aug 7, 2024

This PR addresses a bug I was encountering with fixing up #324. It updates the way the block stack width is calculated. Instead of multiplying the indent and margin size, those two are added together. That seems to match how those two are used in the MarginWriter used by most block elements.

I also updated the Header so that it uses MarginWriter like the other block elements (so padding and such is applied the same way)

Note: This change does seem to result in a global drop in the rendered width by 1-2 spaces since we're evaluating the width and margin as 0 in most cases.

Fixes: #331

@jahvon
Copy link
Contributor Author

jahvon commented Aug 7, 2024

Here are a couple of images to demonstrate the spacing / padding rendered now:

When setting the padding character in MarginWriter to "+"
Screenshot 2024-08-06 at 9 48 15 PM

When updating the document background color
Screenshot 2024-08-06 at 9 50 33 PM

@jahvon jahvon changed the title Fix spacing for block stack elements Fix spacing for block elements Aug 7, 2024
@maxmoehl
Copy link
Contributor

I was looking at this as well but to me it seems like we would have to use margin*2, see my comment for details.

@jahvon
Copy link
Contributor Author

jahvon commented Aug 30, 2024

I was looking at this as well but to me it seems like we would have to use margin*2, see my comment for details.

Great catch and great explanation @maxmoehl. I'll push up an update here

@jahvon jahvon changed the title Fix spacing for block elements fix: render right margin for block stack elements Sep 10, 2024
@rusq
Copy link

rusq commented Nov 25, 2024

Could someone see into merging this? It's a canonical party pooper.

@caarlos0 caarlos0 merged commit 9cedaca into charmbracelet:master Nov 25, 2024
8 checks passed
@caarlos0
Copy link
Member

hey, thanks for the PR, sorry for the delay on merging it :)

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.

Extra new lines between list items when word wrap is set to terminal width
5 participants