From abf96e6ad6ea66e0a6b5ca52611e21eff9f3f70c Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 16 Dec 2021 12:36:27 +0100 Subject: [PATCH] Fix movement tests in `DisplayMap` --- crates/editor/src/display_map.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index 9454455214..ee7dc2acf6 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -641,6 +641,8 @@ mod tests { } // Movement + let min_point = snapshot.clip_point(DisplayPoint::new(0, 0), Left); + let max_point = snapshot.clip_point(snapshot.max_point(), Right); for _ in 0..5 { let row = rng.gen_range(0..=snapshot.max_point().row()); let column = rng.gen_range(0..=snapshot.line_len(row)); @@ -650,7 +652,7 @@ mod tests { let moved_right = movement::right(&snapshot, point).unwrap(); log::info!("Right {:?}", moved_right); - if point < snapshot.max_point() { + if point < max_point { assert!(moved_right > point); if point.column() == snapshot.line_len(point.row()) || snapshot.soft_wrap_indent(point.row()).is_some() @@ -664,13 +666,13 @@ mod tests { let moved_left = movement::left(&snapshot, point).unwrap(); log::info!("Left {:?}", moved_left); - if !point.is_zero() { + if point > min_point { assert!(moved_left < point); if point.column() == 0 { assert!(moved_left.row() < point.row()); } } else { - assert!(moved_left.is_zero()); + assert_eq!(moved_left, point); } } }