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

Merged
merged 4 commits into from
Oct 11, 2024

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

style.go Outdated Show resolved Hide resolved
@bashbunni bashbunni linked an issue Oct 9, 2024 that may be closed by this pull request
@bashbunni bashbunni merged commit 199d3c8 into master Oct 11, 2024
10 checks passed
@bashbunni bashbunni deleted the fix-carriage-returns branch October 11, 2024 17:40
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.

table resizing issue with \r\n in cells
2 participants