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
This commit is contained in:
6 files changed
+17
-30
No files matched your search
+12
-25
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user