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): strip carriage returns from strings #386

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bashbunni
Copy link
Member

@bashbunni bashbunni commented Oct 7, 2024

If a string contains carriage returns \r, it will cause some funky issues when rendering. More specifically any time we do any string concatenation, string A will be overwritten by string B instead of appended.

this is an example log output when a string has a \r and goes through alignHorizontal to pad spaces

2024/10/07 13:36:43 end of horizontal align
git: 'defer' is not a git command. See 'git --help'.
----------------------------------------------------
-----------------------ds are
------------------------------------------
------------------------------------------
----------------------------------------------------

After this change:

2024/10/07 13:53:24 end of horizontal align
git: 'defer' is not a git command. See 'git --help'.
----------------------------------------------------
The most similar commands are-----------------------
    rerere------------------------------------------
    revert------------------------------------------
----------------------------------------------------

related:
charmbracelet/freeze#119

@bashbunni
Copy link
Member Author

Added a test that reproduces this behaviour. I notice that it only happens when Margin is set which is interesting. If you want to see for yourself, run the test on master and you'll see it fail

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.

1 participant