feat(assert): match a cell by its OSC 8 link - #203
Open
Ayman Bagabas (aymanbagabas) wants to merge 1 commit into
Open
feat(assert): match a cell by its OSC 8 link#203Ayman Bagabas (aymanbagabas) wants to merge 1 commit into
Ayman Bagabas (aymanbagabas) wants to merge 1 commit into
Conversation
Recording hyperlinks made them readable through `cells` and snapshots, but not assertable: the style query had no link field, so a test that wanted to check where a link pointed had to shell out to `cells --json` and parse it, which is the thing the style query exists to avoid. `link` joins the other style properties, so it works everywhere they already do: `expect text ... --link`, `get_by_style` / `getByStyle`, and the `within` and `after` locator stages. An empty string is a requirement rather than an absence. `--link ""` asks for a cell that links nowhere, which is how a test asserts that `OSC 8 ;;` closed a link rather than merely that some other link is not present. The `Option` already carries "the caller did not ask", so the inner `String` is free to mean something. Verified against a live session as well as in unit tests: the right URL passes, a wrong URL fails, plain text with a link filter fails, and linked text with an empty link filter fails. Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
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.
Makes OSC 8 links assertable, not just readable.
Why
#181 makes links observable through
cells --jsonand snapshots, but the style query has no link field. So a test that wants to check where a link points has to shell out and parse JSON:That is precisely what the style query exists to avoid.
--fg,--underline-colorand the rest are all first-class; the link was not.What
linkjoins the other style properties, so it works everywhere they already do:Because it is an ordinary style property it also composes with the
within,afterandbeforelocator stages for free.An empty string is a requirement, not an absence
--link ""asks for a cell that links nowhere. That is how a test assertsOSC 8 ;;actually closed a link, rather than only that some other link is absent — a distinction that matters because a link running to the end of the row is exactly the bug #181 found in the xterm.js shim.The
Optionalready carries "the caller did not ask", which leaves the innerStringfree to mean something. HenceOption<String>rather than a bareStringwith a sentinel.Verification
Unit tests cover the matcher: matching URL, non-matching URL, empty-link-vs-linked-cell in both directions, and a style with no link still matching a linked cell (so this does not silently narrow existing queries). A CLI test pins that
--link ""survives parsing as an empty string rather than collapsing toNone.Checked against a live session too, since a parse test would not catch a wiring mistake:
expect text "LINK" --link "https://example.com"expect text "LINK" --link "https://wrong.example"expect text "plain" --link ""expect text "plain" --link "https://example.com"expect text "LINK" --link ""cargo test --workspace --features tui-test-rs/ghostty,tui-test-rs/rio,tui-test-rs/xtermjsgives 633 passed, 0 failed.cargo fmt --checkand bothclippy -D warningsinvocations are clean.