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

normalize_stdout: reset alignment on new lines #128

Merged
merged 1 commit into from
Aug 18, 2024

Conversation

avamsi
Copy link
Contributor

@avamsi avamsi commented Aug 18, 2024

Current code never resets alignment and so fails with cases like
echo '1\t2\n\t3', which both expand and watch handle just fine.

This should fix that, but note that the current code can still be
tripped up by escape sequences etc. (echo '\e[0m1\t2\n\t3', for
example) -- interestingly while expand trips up similar to the current
code, watch --color handles these perfectly.

Current code never resets alignment and so fails with cases like
`echo '1\t2\n\t3'`, which both `expand` and `watch` handle just fine.

This should fix that, but note that the current code can still be
tripped up by escape sequences etc. (`echo '\e[0m1\t2\n\t3'`, for
example) -- interestingly while `expand` trips up similar to the current
code, `watch --color` handles these perfectly.
Copy link
Owner

@sachaos sachaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! LGTM!

@sachaos sachaos merged commit b2211f4 into sachaos:master Aug 18, 2024
4 checks passed
@avamsi avamsi deleted the jj_mtmnlspxzqmx branch August 18, 2024 16:08
@avamsi
Copy link
Contributor Author

avamsi commented Aug 18, 2024

I haven't looked at it closely yet but for posterity, the code at https://github.com/mgeisler/textwrap/blob/63970361d1d653ec8715acb931c3c109750d4a57/src/core.rs#L52 seems to be useful for making this work with escape codes (and possibly unicode characters?).

@sachaos
Copy link
Owner

sachaos commented Aug 18, 2024

@avamsi Thank you! That may solve our problem.
Yes, I thought we should skip escape codes, and handle wide length characters.

@sachaos
Copy link
Owner

sachaos commented Aug 19, 2024

@avamsi I've fixed char width and escape codes problem.
Thank you for the information.
#129

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.

2 participants