From 5831bd7c8d4fbd6deef7117bd587b65556fedfa0 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 24 Jul 2022 16:56:19 -0700 Subject: [PATCH] search: fix coordinates for matches at EOL The returned coords didn't include the last cell on the line; adjust the fallback case to generate an exclusive rather than inclusive end coordinate. --- mux/src/localpane.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mux/src/localpane.rs b/mux/src/localpane.rs index 5a7edb3fb..165f2f5c2 100644 --- a/mux/src/localpane.rs +++ b/mux/src/localpane.rs @@ -628,7 +628,13 @@ impl Pane for LocalPane { .binary_search_by(|ele| ele.byte_idx.cmp(&idx)) .or_else(|i| -> Result { Ok(i) }) .unwrap(); - let coord = coords.get(c).or_else(|| coords.last()).unwrap(); + let coord = coords.get(c).map(|c| *c).unwrap_or_else(|| { + let last = coords.last().unwrap(); + Coord { + grapheme_idx: last.grapheme_idx + 1, + ..*last + } + }); (coord.grapheme_idx, coord.stable_row) }