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

test: add test for chinese character formatting bug #249

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

bashbunni
Copy link
Member

related charmbracelet/glow#499

I'm testing to reproduce the formatting issues in this bug report to confirm if Glamour is responsible for this behaviour. (wip)

@bashbunni
Copy link
Member Author

Tests are failing, but the output isn't hugely helpful... It looks like the ansi code is different on the line where there is a difference, but it doesn't really help me narrow down the issue. The shorter text seems to format correctly which would be consistent with the original issue reported.

=== RUN   TestWrapping
=== RUN   TestWrapping/english_short
=== RUN   TestWrapping/chinese_short
=== RUN   TestWrapping/chinese_long
    glamour_test.go:279: got != want
        -want +got:
        diff:
          string{
          	... // 78204 identical bytes
          	0x6d, 0x1b, 0x5b, 0x33, 0x38, 0x3b, 0x35, 0x3b, 0x32, 0x35, 0x32, 0x6d, 0x1b, 0x5b, 0x30, 0x6d, //  |m.[38;5;252m.[0m|
          	0x20, 0x20, 0x1b, 0x5b, 0x33, 0x38, 0x3b, 0x35, 0x3b, 0x32, 0x35, 0x32, 0x6d, 0x31, 0x3a, 0x34, //  |  .[38;5;252m1:4|
        + 	0x1b, 0x5b, 0x30, 0x6d, 0x1b, 0x5b, 0x33, 0x38, 0x3b, 0x35, 0x3b, 0x32, 0x35, 0x32, 0x6d,       // +|.[0m.[38;5;252m|
          	0x3a, 0x39, 0x1b, 0x5b, 0x33, 0x38, 0x3b, 0x35, 0x3b, 0x32, 0x35, 0x32, 0x6d, 0x20, 0x1b, 0x5b, //  |:9.[38;5;252m .[|
          	0x30, 0x6d, 0x1b, 0x5b, 0x33, 0x38, 0x3b, 0x35, 0x3b, 0x32, 0x35, 0x32, 0x6d, 0x20, 0x1b, 0x5b, //  |0m.[38;5;252m .[|
          	... // 340063 identical bytes
          }
--- FAIL: TestWrapping (0.33s)
    --- PASS: TestWrapping/english_short (0.00s)
    --- PASS: TestWrapping/chinese_short (0.00s)
    --- FAIL: TestWrapping/chinese_long (0.33s)
FAIL

@bashbunni
Copy link
Member Author

bashbunni commented Aug 15, 2023

Soooo this is what cmp.Diff does when an output is considered "non-printable". The |.[0m.[38;5;252m| is what differed between the got and want values and this only happens with long chinese text. So far I've tried short english, short chinese, long latin, and long chinese and the final test is the only one failing so I think I've successfully reproduced the issue... Now to try and figure out what that issue is exactly and how to fix it 👍

(also thanks to the Go team for helping me figure out how to read the output: google/go-cmp#334)

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