Repository navigation
Keep redundant OSC 8 closes in the outer clipping cursor context - #308
RealBhupesh wants to merge 3 commits into
Conversation
Do not process the text between redundant OSC 8 closes as a hyperlink unit. Preserve the existing adjacent empty-unit behavior. Developed with AI assistance. Assisted-by: LLM LLM: gpt-6-luna
Check BEL and ST terminators across three clipping windows with explicit visible output expectations. Developed with AI assistance. Assisted-by: LLM LLM: gpt-6-luna
|
This is borderline "unlikely sequence", and documented here and references this issue, https://wcwidth.readthedocs.io/en/latest/intro.html#unlikely-sequences but if performance impact is negligible, I think I may accept it, it is probably best to prevent additional AI Agents from boiling water to make the same "bugfixes" of non-likely sequences, redundant closing tags are a bit like html and should probably not have run-on or ambient effects |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #308 +/- ##
=======================================
Coverage 88.74% 88.74%
=======================================
Files 41 41
Lines 5669 5671 +2
Branches 1522 1523 +1
=======================================
+ Hits 5031 5033 +2
Misses 254 254
Partials 384 384 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for the review. I checked the existing Compared upstream Same-output controls, microseconds per call:
The four existing redundant-close tab/CR fixtures (BEL and ST) also produced the expected outputs for both revisions. Their measured times were lower on the PR, but the outputs and work differ because of the correction, so I wouldn't use them as an equivalent-output speed comparison. No apparent large slowdown showed up in these two short controls in this environment. This is a small local measurement, not an equivalence test or a guarantee of negligible impact: only seven pairs, no CPU affinity/frequency control, no C-extension measurement, and no broad workload coverage. |
This is PR #308 with tests and comments rewritten. This is something of an Unlikely Sequence, it would be a bug in any TUI library to generate extra close tags. Like an extra/errant HTML close tag, we should strive not to have strange side-effects when they are present, defending against it has negligible performance. > Do not process the text between redundant OSC 8 closes as a hyperlink unit. Preserve the existing adjacent empty-unit behavior. > > Developed with AI assistance. > > Assisted-by: LLM > LLM: gpt-6-luna --------- Co-authored-by: Bhupesh Cholake <[email protected]>
|
Thanks, it is merged for next release by #319 |
A legal OSC 8 close without an active link can make
clip()treat ordinary following text as a hyperlink unit, up to the next close. That inner text is then measured/clipped from column zero, losing its actual cursor position.The OSC 8 description explicitly allows closing a hyperlink when none is open.
When empty-URL parameters are followed by nonempty text before the next close, use the existing ordinary-sequence fallback instead of processing a hyperlink unit. This keeps the following text in the outer cursor context. Adjacent empty close-close units retain their existing behavior.
HyperlinkParams.parse()is unchanged.Added 12 cases covering BEL/ST terminators, tabs/carriage returns and three clipping windows, with explicit visible output expectations.
Validation on Python 3.10 after editable installation:
WCWIDTH_PYTHON=1): 1,782 passed, 47 skipped.git diff --checkpass.Scope: this fixes redundant closes, not general cursor movement inside genuine hyperlink contents. Arbitrary escape insertion inside a grapheme cluster can expose separate preexisting segmentation differences and is not claimed fixed. No coverage percentage or CI result is claimed.
Developed and tested with AI assistance.