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 wrapping of colored values #229

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

Conversation

devdanzin
Copy link
Collaborator

Sometimes tabulate will create broken wrapping tables by wrapping in the middle of ANSI escape codes. A fix has been proposed at the tabulate repository, but the project seems to be dormant at the moment.

This PR uses the code from the fix to monkeypatch tabulate._CustomTextWrap._handle_long_word in report() and diff(), so we don't have the bug. A test is included.

Before patch:

├────────────┼─────────────┼───────────┼────────────┼──────────────┼────────────┼───────────────┼────────────┤
│ dbe9172    │ Add unit    │ devdanzin │ 2023-09-24 │ 14.9615      │ 74 (0)     │ 78.5874 ( 3381 (+1)  │
│            │ tests for   │           │            │ (0.0)        │            │ 31m-0.00851   │            │
│            │ some        │           │            │              │            │ 093)          │            │
│            │ commands    │           │            │              │            │               │            │
│            │ (#199)  *   │           │            │              │            │               │            │
│            │ Add uni     │           │            │              │            │               │            │
├────────────┼─────────────┼───────────┼────────────┼──────────────┼────────────┼───────────────┼────────────┤
│ d0ad384    │ Add some    │ devdanzin │ 2023-09-22 │ 14.9615 ( 74 (-1)    │ 78.5959       │ 3380 (-15) │
│            │ more typing │           │            │ 32m-0.03846  │            │ (-0.306704)   │            │
│            │ (#221)  *   │           │            │ 15)          │            │               │            │
│            │ Update      │           │            │              │            │               │            │
│            │ typing info │           │            │              │            │               │            │
├────────────┼─────────────┼───────────┼────────────┼──────────────┼────────────┼───────────────┼────────────┤

broken_color_wrap

After patch:

├────────────┼─────────────┼───────────┼────────────┼──────────────┼────────────┼───────────────┼────────────┤
│ dbe9172    │ Add unit    │ devdanzin │ 2023-09-24 │ 14.9615      │ 74 (0)     │ 78.5874 (-0   │ 3381 (+1)  │
│            │ tests for   │           │            │ (0.0)        │            │ .00851093)    │            │
│            │ some        │           │            │              │            │               │            │
│            │ commands    │           │            │              │            │               │            │
│            │ (#199)  *   │           │            │              │            │               │            │
│            │ Add uni     │           │            │              │            │               │            │
├────────────┼─────────────┼───────────┼────────────┼──────────────┼────────────┼───────────────┼────────────┤
│ d0ad384    │ Add some    │ devdanzin │ 2023-09-22 │ 14.9615 (-0  │ 74 (-1)    │ 78.5959       │ 3380 (-15) │
│            │ more typing │           │            │ .0384615)    │            │ (-0.306704)   │            │
│            │ (#221)  *   │           │            │              │            │               │            │
│            │ Update      │           │            │              │            │               │            │
│            │ typing info │           │            │              │            │               │            │
├────────────┼─────────────┼───────────┼────────────┼──────────────┼────────────┼───────────────┼────────────┤

fixed_color_wrap

@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2024

Codecov Report

Attention: Patch coverage is 76.47059% with 8 lines in your changes missing coverage. Please review.

Project coverage is 95.39%. Comparing base (2590691) to head (987f1b3).

Files with missing lines Patch % Lines
src/wily/helper/__init__.py 80.76% 3 Missing and 2 partials ⚠️
src/wily/commands/diff.py 50.00% 1 Missing and 1 partial ⚠️
src/wily/commands/report.py 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #229      +/-   ##
==========================================
- Coverage   95.86%   95.39%   -0.47%     
==========================================
  Files          25       25              
  Lines        1403     1434      +31     
  Branches      296      305       +9     
==========================================
+ Hits         1345     1368      +23     
- Misses         33       37       +4     
- Partials       25       29       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

siddhu032d

This comment was marked as spam.

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.

3 participants