aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-03-04 02:23:05 +0000
committerBlaž Hrastnik2022-03-04 02:23:05 +0000
commitd62ad8b595a4f901b9c5dba1bb6e8f70ece395bf (patch)
tree52418b5d2dddc15227191e6e54ac1e48633f2b1f
parentfd02d1bf8966754624c733790c20bb8431e1eb54 (diff)
fix: text_pos_at_screen_coords tests
-rw-r--r--helix-view/src/view.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index b427a8d4..c6ae0c56 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -260,7 +260,7 @@ impl View {
// If pos is in the middle of a wider grapheme (tab for example)
// return the starting offset.
- if col + width >= target {
+ if col + width > target {
break;
}
@@ -356,7 +356,7 @@ mod tests {
assert_eq!(
view.text_pos_at_screen_coords(&text, 41, 40 + OFFSET + 1, 4),
- Some(5)
+ Some(4)
);
assert_eq!(
@@ -385,8 +385,12 @@ mod tests {
);
assert_eq!(
+ view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET + 4, 4),
+ Some(4)
+ );
+ assert_eq!(
view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET + 5, 4),
- Some(5)
+ Some(4)
);
assert_eq!(
@@ -396,7 +400,7 @@ mod tests {
assert_eq!(
view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET + 7, 4),
- Some(6)
+ Some(5)
);
assert_eq!(