fix hyperlink underlines
There were two problems: * We weren't correctly invalidating when the hover state changed (a recent regression caused by recent caching changes) * We'd underline every link with the same destination on hover, not just the one under the mouse (longstanding wart) Recent changes allow the application layer to reference the underlying Lines directly, so we can restore the original and expected only-highlight-under-the-mouse by switching to those newer APIs. Adjust the cache values so that we know to also verify the current highlight and invalidate. I was a little surprised to see that this also works with mux client panes: I was expecting to need to do some follow up on those because they return copies of Line rather than references to them. That happens to work because the mux client updates the hyperlinks at the time where it inserts into its cache. The effect of that is that lines in mux client panes won't update to new hyperlink rules if they were received prior to a change in the config. refs: https://github.com/wez/wezterm/issues/2496
This commit is contained in:
1 parent
77ed919098
commit
026b9e3577
5 files changed
+108
-93
No files matched your search
@@ -170,28 +170,6 @@ impl LogicalLine {
|
||||
}
|
||||
(y - 1, x - idx + self.physical_lines.last().unwrap().len())
|
||||
}
|
||||
|
||||
pub fn apply_hyperlink_rules(&mut self, rules: &[Rule]) {
|
||||
let seq = self.logical.current_seqno();
|
||||
self.logical.invalidate_implicit_hyperlinks(seq);
|
||||
self.logical.scan_and_create_hyperlinks(rules);
|
||||
if !self.logical.has_hyperlink() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Re-compute the physical lines
|
||||
let mut line = self.logical.clone();
|
||||
let num_phys = self.physical_lines.len();
|
||||
for (idx, phys) in self.physical_lines.iter_mut().enumerate() {
|
||||
let len = phys.len();
|
||||
let seq = seq.max(phys.current_seqno());
|
||||
let remainder = line.split_off(len, seq);
|
||||
*phys = line;
|
||||
line = remainder;
|
||||
let wrapped = idx == num_phys - 1;
|
||||
phys.set_last_cell_was_wrapped(wrapped, seq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A Pane represents a view on a terminal
|
||||
@@ -260,42 +238,6 @@ pub trait Pane: Downcast {
|
||||
self.for_each_logical_line_in_stable_range_mut(lines, &mut ApplyHyperLinks { rules });
|
||||
}
|
||||
|
||||
fn get_lines_with_hyperlinks_applied(
|
||||
&self,
|
||||
lines: Range<StableRowIndex>,
|
||||
rules: &[Rule],
|
||||
) -> (StableRowIndex, Vec<Line>) {
|
||||
if rules.is_empty() {
|
||||
return self.get_lines(lines);
|
||||
}
|
||||
let requested_first = lines.start;
|
||||
let num_lines = (lines.end - lines.start) as usize;
|
||||
let logical = self.get_logical_lines(lines);
|
||||
|
||||
let mut first = None;
|
||||
let mut phys_lines = vec![];
|
||||
'outer: for mut log_line in logical {
|
||||
log_line.apply_hyperlink_rules(rules);
|
||||
for (idx, phys) in log_line.physical_lines.into_iter().enumerate() {
|
||||
if log_line.first_row + idx as StableRowIndex >= requested_first {
|
||||
if first.is_none() {
|
||||
first.replace(log_line.first_row + idx as StableRowIndex);
|
||||
}
|
||||
phys_lines.push(phys);
|
||||
if phys_lines.len() == num_lines {
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if first.is_none() {
|
||||
assert_eq!(phys_lines.len(), 0);
|
||||
}
|
||||
|
||||
(first.unwrap_or(0), phys_lines)
|
||||
}
|
||||
|
||||
/// Returns render related dimensions
|
||||
fn get_dimensions(&self) -> RenderableDimensions;
|
||||
|
||||
|
||||
Reference in new issue
Block a user