Skip to content

Conversation

@ps06756
Copy link

@ps06756 ps06756 commented Dec 28, 2025

Summary

  • Adds sequence-aware _split() override in SequenceTextWrapper to properly handle break_on_hyphens when text contains escape sequences
  • Adds test coverage for break_on_hyphens parameter

Problem

When text had per-character escape sequences (e.g., each letter colored separately), the parent's _split() regex couldn't correctly identify hyphens as break points because escape sequences were mixed into the text.

Solution

The new _split() method:

  1. Strips sequences to get the "logical" text
  2. Calls the parent's _split() on stripped text to find break points
  3. Maps those break points back to the original text with sequences intact

Fixes #329

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.13%. Comparing base (cee680f) to head (0e3b6d8).

Files with missing lines Patch % Lines
blessed/sequences.py 94.11% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #330      +/-   ##
==========================================
- Coverage   98.35%   98.13%   -0.22%     
==========================================
  Files          11       11              
  Lines        2491     2524      +33     
  Branches      438      410      -28     
==========================================
+ Hits         2450     2477      +27     
- Misses         31       34       +3     
- Partials       10       13       +3     

☔ View full report in Codecov by Sentry.
📢 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.

@avylove
Copy link
Collaborator

avylove commented Jan 8, 2026

We'll need conditional logic, either in the code or the test to account for the <= 3.9 behavior, whichever @jquast prefers

Not sure what's going on with the linting job, looks like an unrelated tox/docformater issue.

@jquast
Copy link
Owner

jquast commented Jan 8, 2026

I think it is fine to mark test_break_on_hyphens as ignored for python 3.9 and earlier as previously suggested.

I think it is OK to provide this "improved" textwrap behavior with Terminal.wrap() on older versions of python, even if it does not exactly match textwrap.wrap() on that version -- In the same way that 3rd libraries bring "backports" or improves upon standard libraries.


I'll look at the linting issue with another PR, there are a number of issues more than just docformatter with unexplained exit code 3, all other tools are skipped due to the 3.13/3.14 mixed environment requirement in a single tox execution not satisfied by container python:3.14 image, due to PyCQA/docformatter#327

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.

Handle break_on_hyphens with wrap

3 participants