fix-deviant(links): bound hover lookup and renderer regex work

Follow-up testing showed that the mailbox limit did not fix the base64
hang: moving the pointer stalled the app, and opening a tab could hang it.
Mouse link lookup copied the entire wrapped line before checking modifier
eligibility, while renderer link searches had no whole-search work budget.

Filter eligible links before traversing scrollback. Add bounded logical
line selection and skip automatic regex lookup on lines exceeding 65,536
grid cells. Keep explicit line selection and OSC8 handling unrestricted.
Skip oversized lines instead of truncating URLs into different targets.

Apply the existing terminal StringMap retry budget to renderer searches
and handle search errors without panicking. The regression triggered a
retry-limit panic through the old onig search API and now returns normally,
allowing subsequent link patterns to run.

Document the lookup limits and correct the earlier mailbox fix entry to
record that it did not resolve the reported hang on its own.

Test Plan:
- 1,513 unit/integration tests and one doctest pass across core, renderer,
  and terminal with Mesa software OpenGL; one existing doctest is ignored.
- Release application build, formatting, and all-target Clippy pass.
- GTK handles 400 pointer moves, including Ctrl hover, during continuous
  base64 output, opens/closes a tab, handles Ctrl+C, prints a marker, and
  exits cleanly. Normal URL hover still works after a hard newline.

Reference: docs/rewrite/DEVIANT_FIXES.md (entry 41)
This commit is contained in:
ddidderr committed 2026-10-15 00:02:47 +02:00
1 parent 4c31d27888
commit 9010117d08
9 files changed
+153 -24

No files matched your search

+14
View File
@@ -2653,7 +2653,16 @@ impl Screen {
/// over whitespace but the line has non-whitespace characters elsewhere, the
/// line will be selected.
pub fn select_line(&self, opts: SelectLine<'_>) -> Option<Selection> {
self.select_line_bounded(opts, usize::MAX)
}
/// Select a complete logical line only if it spans at most `max_rows`
/// physical rows. This bounds interactive link lookup on unbroken output
/// without truncating a URL into a different, clickable target. Explicit
/// line selection uses [`Self::select_line`] and remains unrestricted.
pub fn select_line_bounded(&self, opts: SelectLine<'_>, max_rows: usize) -> Option<Selection> {
let list = &self.pages;
let mut remaining = max_rows.checked_sub(1)?; // The hovered row.
// Get the current point semantic prompt state since that determines
// boundary conditions too. This makes it so that line selection can
@@ -2698,6 +2707,8 @@ impl Screen {
break 'start_pin copy;
}
remaining = remaining.checked_sub(1)?;
if let Some(v) = semantic_prompt_state {
// We need to check every cell in this row in reverse
// order since we're going up and back.
@@ -2726,6 +2737,9 @@ impl Screen {
// The real end of the row is the final row in the soft-wrap.
let end_pin: Pin = 'end_pin: {
for p in opts.pin.row_iterator(list, Direction::RightDown, None) {
if p.node != opts.pin.node || p.y != opts.pin.y {
remaining = remaining.checked_sub(1)?;
}
let row = self.pin_row(p);
let cols = self.pin_cols(p);
@@ -292,6 +292,39 @@ fn screen_select_line_across_full_soft_wrap() {
expect_sel(&s, &sel, Tag::Screen, (0, 0), (4, 1));
}
#[test]
fn screen_select_line_bounded_counts_both_directions_and_history() {
let mut s = init(4, 3, 100_000);
s.test_write_string("abcdefghijklmnopqrstuvwx").unwrap();
for y in 0..6 {
let opts = SelectLine {
pin: pin(&s, screen_pt(1, y)),
whitespace: None,
semantic_prompt_boundary: false,
};
assert!(s.select_line_bounded(opts, 0).is_none());
assert!(s.select_line_bounded(opts, 5).is_none());
assert_eq!(s.select_line_bounded(opts, 6), s.select_line(opts));
assert!(s.select_line_bounded(opts, 6).is_some());
}
}
#[test]
fn screen_select_line_bounded_stops_at_hard_line_boundary() {
let mut s = init(4, 5, 0);
s.test_write_string("HEAD\nabcdefghijkl\nTAIL").unwrap();
for y in 1..4 {
let opts = SelectLine {
pin: pin(&s, screen_pt(1, y)),
whitespace: None,
semantic_prompt_boundary: false,
};
let sel = s.select_line_bounded(opts, 3).unwrap();
assert_eq!(sel, s.select_line(opts).unwrap());
assert!(s.select_line_bounded(opts, 2).is_none());
}
}
#[test]
fn screen_select_line_across_soft_wrap_ignores_blank_lines() {
let mut s = init(5, 10, 0);