Render Markdown web links as labels in Rex (#53725)

## What changed

Select label-only web link rendering when `TERM_PROGRAM` is `rex`, matched case-insensitively. Preserve the existing visible-destination fallback for multiplexers and `dumb`, `screen`, or `tmux` terminal modes.

## Testing

Add a regression test verifying that Rex renders `[label](https://example.com)` with the label-only policy.

GitOrigin-RevId: 615ca6186d84fc17cef9286e75848877b542b6ab
This commit is contained in:
Benjamin Carlsson
2026-10-13 17:30:45 +00:00
committed by copyberry
parent 703d253ed6
commit 72ad8747e9
2 changed files with 22 additions and 0 deletions
@@ -69,6 +69,13 @@ impl WebLinkDisplay {
{
return Self::WithDestination;
}
if terminal
.term_program
.as_deref()
.is_some_and(|program| program.eq_ignore_ascii_case("rex"))
{
return Self::LabelOnly;
}
match terminal.name {
TerminalName::Ghostty
| TerminalName::Iterm2
@@ -143,6 +143,21 @@ fn supporting_terminals_render_only_the_styled_label_and_keep_its_target() {
}
}
#[test]
fn rex_renders_only_the_label() {
let mut rex = terminal(TerminalName::Unknown);
rex.term_program = Some("rex".to_string());
let markdown = "[label](https://example.com)";
assert_eq!(
render(
markdown,
/*width*/ 80,
WebLinkDisplay::for_terminal(&rex, /*term*/ None),
),
render(markdown, /*width*/ 80, WebLinkDisplay::LabelOnly),
);
}
#[test]
fn unknown_terminals_and_multiplexers_keep_visible_destinations() {
let mut tmux = terminal(TerminalName::Ghostty);