T45: round 2 fix: while herdr takes the mouse every link press is herdr's again, its rules with it, as its client and docs say: it keeps its panes' OSC 8 targets from the terminal so that it alone answers Ctrl-press, and opens web links only, so the terminal opening a file:// label it sees opened the wrong target; Shift with the press, herdr's named way past it, lets the terminal open what it sees, a file:// link too
CI / platforms (windows-latest) (push) Failing after 10s
CI / platforms (ubuntu-24.04) (push) Successful in 1m44s
CI / macos (push) Canceled after 0s

This commit is contained in:
ZacharyZhang-NY committed 2026-10-18 04:54:55 -04:00
1 parent af66a70947
commit c30bd51fba
6 files changed
+17 -30

No files matched your search

+12 -25
View File
@@ -115,21 +115,19 @@ impl TerminalView {
event.modifiers.control
};
let tracking = self.tracking(&event.modifiers);
if event.button == MouseButton::Left && opens {
// herdr opens its panes' links itself, whole where its drawing wraps them.
let herdr = self.herdr && tracking != Tracking::Off;
if event.button == MouseButton::Left && opens && herdr {
log::debug!(
"terminal {}: herdr takes the link press at {cell:?}",
self.pty.pid
);
} else if event.button == MouseButton::Left && opens {
let link = link_at(&self.pty.term.lock(), point);
// herdr opens web links itself, whole where its drawing wraps them; it opens no other kind.
let herdr = self.herdr && tracking != Tracking::Off;
match link {
Some(link) if !(herdr && web(&link)) => {
log::info!("terminal {}: opens {link}", self.pty.pid);
cx.open_url(&link);
return;
}
_ if herdr => log::debug!(
"terminal {}: herdr takes the link press at {cell:?}",
self.pty.pid
),
_ => {}
if let Some(link) = link {
log::info!("terminal {}: opens {link}", self.pty.pid);
cx.open_url(&link);
return;
}
}
if tracking != Tracking::Off {
@@ -397,11 +395,6 @@ fn everything<T>(term: &Term<T>) -> Option<Selection> {
Some(all)
}
/// A link herdr opens: a web one, as its client's `safe_web_url` checks.
fn web(link: &str) -> bool {
link.starts_with("http://") || link.starts_with("https://")
}
#[cfg(test)]
mod tests {
use alacritty_terminal::{
@@ -421,12 +414,6 @@ mod tests {
term.selection_to_string()
}
#[test]
fn herdr_takes_web_links_and_leaves_the_rest() {
assert!(web("https://ely.dev/x") && web("http://ely.dev"));
assert!(!web("file:///etc/hosts") && !web("mailto:ely@ely.dev"));
}
#[test]
fn everything_runs_from_the_first_character_in_the_history_to_the_last() {
assert_eq!(all(b""), None, "a blank grid selects nothing");