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

rendering bug on small spans in large spans #316

Merged
merged 3 commits into from
Nov 15, 2023

Conversation

jdonszelmann
Copy link
Contributor

@jdonszelmann jdonszelmann commented Nov 8, 2023

See #317. This contributes a test for #317 and then fixes the bug :)

Closes #317

The bad screenshot from #317

image

now becomes this with the proposed changes:

image

Note that there were actually two subtle bugs. One was the double arrow in the gutter problem, which also occurred when rendering without ansi escape codes. However, this line

write!(f, "{:width$}", gutter, width = max_gutter + 1)?;

Also did not work when the gutter contains ansi escape codes. It extends to the width variable, but when the string contains ansi codes it does not actually add any spaces since it thinks the escape codes have width as well. They of course do not, so the output doesn't look right. Unfortunately this is quite hard to make tests for.

It turned out there were two really. One related to how many characters
were added for the arrowheads in the gutter, and one where the gutter
was extended to a number of characters, including ansi escape codes.
However, because ansi escape codes are rather big, there would never be
any extension since the system thought the string was already long
enough, even though you don't actually see the width of those codes.
@zkat
Copy link
Owner

zkat commented Nov 15, 2023

Can you fix the conflicts here?

@jdonszelmann
Copy link
Contributor Author

Yes! One sec

@jdonszelmann
Copy link
Contributor Author

@zkat there ya go! Thanks for having started such an awesome project 💖

@zkat zkat merged commit 7ff4f87 into zkat:main Nov 15, 2023
11 checks passed
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.

Rendering bug on small spans in large spans
2 participants