fix(terminal): stop URL wrap detection swallowing the next line - #186
Merged
Conversation
Phase 2 extends a URL onto the following row when a TUI wraps the line itself (no WRAPLINE flag). Its "URL reaches the end of the content" guard compared against the URL row's own trimmed length, which is satisfied by every row that happens to end with a URL — so any continuation whose first token contains a slash was absorbed. Claude Code's PR output hit this: the branch name on the next line ended up inside the link. https://github.com/org/repo/pull/4 (docs/data-flow-findings-and-system-audit -> main). A mid-token wrap fills the row to the layout edge, so a continuation row can never be wider than the row it continues. Reject the extension when the next row is wider (same +3 tolerance the other guards use), and track the URL's end column across rows so later iterations compare against the right row. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JZXzxKAXvZc2RrjYWRAbMX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Phase 2 of URL detection (
links.rs) extends a URL onto the following row when a TUI wraps the line itself, i.e. without aWRAPLINEflag. Its "URL reaches the end of the visible content" guard compared the URL's end against the URL row's own trimmed length — trivially satisfied by every row that ends with a URL. From there the only thing standing between the URL and the next line was the weak-extension guard, which lets through any token containing a/.Claude Code's PR output hit exactly that shape, so the branch name landed inside the link:
Detected text before the fix:
The whole branch name was underlined and clicking the link opened the wrong URL.
Fix
A mid-token wrap fills the row to the layout edge, so a continuation row can never be wider than the row it continues. In the case above the URL row ends at column 46 while the next row runs to 52 — proof that the break was a word break, not a wrap.
+3tolerance the other guards use.url_end_colacross iterations so multi-row extensions compare against the row they actually continue.Phase 1 (real
WRAPLINEwraps) is untouched.Tests
New regression test
detect_url_not_extended_when_next_line_is_longer, built from the screenshot above.cargo test -p okena-terminal→ 173 passed, 0 failed. All existing wrap tests still pass, includingdetect_url_wrapped_tui_narrow_layoutanddetect_url_wrapped_with_trailing_text, which cover genuine TUI-wrapped URLs.🤖 Generated with Claude Code
https://claude.ai/code/session_01JZXzxKAXvZc2RrjYWRAbMX