-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
Change how size of headers are calculated to fix ColorTable with title #299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Please could you:
-
Update the title to be more descriptive? It will be used in the release notes. See https://github.com/jazzband/prettytable/releases to get an idea.
-
Add "Fixes #xxx" with the issue number to the PR description, so the issue will be closed when this is merged.
-
Add tests. It's good none of the existing tests fail. It will be even better to add tests which fail with current
main
and pass with this PR, so we can avoid regressions in the future.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
for more information, see https://pre-commit.ci
I will try to get the tests done today. I did change the PR description. Does the new description satisfy the first two requirements in your list? |
Looks good, except please move "Fixes #xxx" from the title to PR the description. |
I added Fixes #290 to my original comment. I don't contribute very often, so if I did this wrong, please let me know. |
for more information, see https://pre-commit.ci
I added a basic test for the color table. Please see commit df8f2e6 and provide feedback as necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Fixes #290
The issue that the
ColorTable
is experiencing deals with its incorporation of ANSI escape character sequences. TheColorTable
class works by incorporating ANSI escape character sequences both before and after the character it represents. That creates a discrepancy in howPrettyTable
andColorTable
portray the same character.I altered how
_stringify_title
computes its width. Instead of relying onself._hrule
, it now uses the padding widths and the widths of the columns themselves. From my testing, this seems to work well. I also modified the way_stringify_header
slices thebits
value. The old code used hard values of1
and-1
, which doesn't account for the length of a single character when someone usesColorTable
.If you see anything that stands out, or you have input on a different solution, please let me know. I am open to the discussion. Also, I didn't see any tests related to the table rendering for
ColorTable
, so I didn't add any. All of the original tests are passing for bothColorTable
andPrettyTable
with these recent changes.