feat(terminal): stitch hard-wrapped file references at click time - #174
feat(terminal): stitch hard-wrapped file references at click time#174ghackett wants to merge 1 commit into
Conversation
When the CLI hard-wraps a long path (a real newline plus continuation indent), the screen holds two separate fragments and no regex can match across them. Clicking either fragment now stitches: geometry-gated (the fragment must touch its row's edge — the signature of a wrapped token), joined with the adjacent token of neighbour rows (chaining across whole-row middle fragments, 2 up / 3 down), re-matched against FILE_PATTERN, and existence-checked like any other candidate. Stitching runs before direct resolution: the leading fragment of a wrapped path is often an existing directory prefix, and the stitched whole is the truer reading. Verified live: both fragments of a hard-wrapped absolute path open the full file (the head fragment alone resolves to .claude/worktrees — the ordering hazard), a mid-row bogus candidate stays inert, and the y-to-row math holds under pixel scrolling with a scrolled-back buffer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dpjh2MJkFJNTjUbbZm1tSN
4584ae6 to
ea6cebc
Compare
|
@claude review |
|
Claude finished @ghackett's task in 4m 24s —— View job Claude finished the review
|

Stacked on #173. Live testing there showed the one annoying gap: when the CLI hard-wraps a long path in its output, the screen genuinely contains two strings separated by a newline and indent, so the reference was inert however you clicked it.
How it works
Clicking a fragment that fails (or shouldn't win) direct resolution now tries stitching before giving up:
FILE_PATTERN(shedding trailing punctuation, keeping a:line[:col]suffix that landed on the continuation row) and must exist on disk. A stitch that guesses wrong opens nothing.…/.claude/worktrees), and without the reordering the click opens the file manager there instead of the file the reference actually names. The stitcher returns fast for unwrapped references, so ordinary clicks don't pay for it.The stitcher is pure and GTK-free (
resolve_wrapped_referencein linkpatterns.py, unit-tested); terminal.py only converts the click's y into a buffer row (pixel- and row-unit scrolling both handled, ±1 row slop for VTE's inner border) and feeds neighbour row texts.Verification
🤖 Generated with Claude Code
https://claude.ai/code/session_01Dpjh2MJkFJNTjUbbZm1tSN