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.
This commit is contained in:
Wez Furlong committed 2022-07-24 16:56:19 -07:00
1 parent ec46aba089
commit 5831bd7c8d
1 file changed
+7 -1
+7 -1
View File
@@ -628,7 +628,13 @@ impl Pane for LocalPane {
.binary_search_by(|ele| ele.byte_idx.cmp(&idx))
.or_else(|i| -> Result<usize, usize> { 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)
}