Skip to content

bugfix: clip() should behave like propagate_sgr() - #235

Merged
jquast merged 1 commit into
masterfrom
jq/clip-fix-1
Aug 28, 2026
Merged

jquast merged 1 commit into
masterfrom
jq/clip-fix-1

Conversation

@jquast

@jquast jquast commented Aug 28, 2026 •

Copy link
Copy Markdown
Owner

Makes wcwidth.clip() function better match behavior of propagate_sgr(), from jquast/blessed#402.

before this change:

>>> wcwidth.clip('\x1b[1mbold\x1b[m normal', 0, 20)
'\x1b[1mbold normal\x1b[0m'      # before: ' normal' became bold
>>> wcwidth.clip('\x1b[31mred\x1b[32mgreen\x1b[0m', 0, 4)
'\x1b[31mredg\x1b[0m'            # before: 'g' is red

after this change:

>>> import wcwidth;wcwidth.clip('\x1b[1mbold\x1b[m normal', 1, 9)
'\x1b[1mbold\x1b[m normal'       # after: identity, nothing was clipped
>>> wcwidth.clip('\x1b[31mred\x1b[32mgreen\x1b[0m', 0, 4)
'\x1b[31mred\x1b[32mg\x1b[0m'    # after: 'g' is green

@jquast jquast changed the title bugfix clip() should be like propagate_sgr ! bugfix: clip() should behave like propagate_sgr() Aug 28, 2026
@codecov

codecov Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (551710e) to head (7f62295).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #235   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         1973      1976    +3     
  Branches       464       463    -1     
=========================================
+ Hits          1973      1976    +3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 108 untouched benchmarks


Comparing jq/clip-fix-1 (7f62295) with master (551710e)

Open in CodSpeed

Also pin and bump pylint and isort, no effect
@jquast
jquast marked this pull request as ready for review August 28, 2026 17:08
@jquast
jquast merged commit 8364c23 into master Aug 28, 2026
34 checks passed
@jquast
jquast deleted the jq/clip-fix-1 branch August 28, 2026 17:27
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