mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 13:21:38 +03:00
quickselect: fixup edge case with wrapped lines
the binary search would falsely extend the end of the match to the start of the subsequent match for the wrapped line case. The resolution is to emit a coordinate for the newline that we add to the haystack between the wrapped lines. closes: https://github.com/wez/wezterm/issues/732
This commit is contained in:
parent
d547f45714
commit
94c98aa826
@ -298,6 +298,7 @@ impl Pane for LocalPane {
|
||||
let mut haystack = String::new();
|
||||
let mut coords = vec![];
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct Coord {
|
||||
byte_idx: usize,
|
||||
grapheme_idx: usize,
|
||||
@ -388,7 +389,14 @@ impl Pane for LocalPane {
|
||||
|
||||
if !wrapped {
|
||||
if let Pattern::Regex(_) = &pattern {
|
||||
haystack.push('\n');
|
||||
if let Some(coord) = coords.last().copied() {
|
||||
coords.push(Coord {
|
||||
byte_idx: haystack.len(),
|
||||
grapheme_idx: coord.grapheme_idx + 1,
|
||||
..coord
|
||||
});
|
||||
haystack.push('\n');
|
||||
}
|
||||
} else {
|
||||
collect_matches(&mut results, &pattern, &haystack, &coords);
|
||||
haystack.clear();
|
||||
|
@ -23,18 +23,18 @@ const PATTERNS: [&str; 14] = [
|
||||
// markdown_url
|
||||
r"\[[^]]*\]\(([^)]+)\)",
|
||||
// url
|
||||
r"(?:https?://|git@|git://|ssh://|ftp://|file:///)[^ ]+",
|
||||
r"(?:https?://|git@|git://|ssh://|ftp://|file:///)\S+",
|
||||
// diff_a
|
||||
r"--- a/([^ ]+)",
|
||||
r"--- a/(\S+)",
|
||||
// diff_b
|
||||
r"\+\+\+ b/([^ ]+)",
|
||||
r"\+\+\+ b/(\S+)",
|
||||
// docker
|
||||
r"sha256:([0-9a-f]{64})",
|
||||
// path
|
||||
r"(?:[.\w\-@~]+)?(?:/[.\w\-@]+)+",
|
||||
// color
|
||||
r"#[0-9a-fA-F]{6}",
|
||||
// uid
|
||||
// uuid
|
||||
r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",
|
||||
// ipfs
|
||||
r"Qm[0-9a-zA-Z]{44}",
|
||||
|
Loading…
Reference in New Issue
Block a user