aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-core/src/search.rs1
-rw-r--r--helix-term/src/ui/editor.rs18
2 files changed, 16 insertions, 3 deletions
diff --git a/helix-core/src/search.rs b/helix-core/src/search.rs
index 7dd2f4fc..73be68c7 100644
--- a/helix-core/src/search.rs
+++ b/helix-core/src/search.rs
@@ -41,7 +41,6 @@ pub fn find_nth_prev(
inclusive: bool,
) -> Option<usize> {
// start searching right before pos
- pos = pos.saturating_sub(1);
let mut chars = text.chars_at(pos);
for _ in 0..n {
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index f47d6c26..8ce9cdc8 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -261,7 +261,16 @@ impl EditorView {
Rect::new(
viewport.x + start.col as u16,
viewport.y + start.row as u16,
- ((end.col - start.col) as u16 + 1).min(viewport.width),
+ // .min is important, because set_style does a
+ // for i in area.left()..area.right() and
+ // area.right = x + width !!! which shouldn't be > then surface.area.right()
+ // This is checked by a debug_assert! in Buffer::index_of
+ ((end.col - start.col) as u16 + 1).min(
+ surface
+ .area
+ .width
+ .saturating_sub(viewport.x + start.col as u16),
+ ),
1,
),
selection_style,
@@ -290,7 +299,12 @@ impl EditorView {
);
}
surface.set_style(
- Rect::new(viewport.x, viewport.y + end.row as u16, end.col as u16, 1),
+ Rect::new(
+ viewport.x,
+ viewport.y + end.row as u16,
+ (end.col as u16).min(viewport.width),
+ 1,
+ ),
selection_style,
);
}