From 4c227746942776ecd70f79e9d3410e30fbe9bdee Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 15 Dec 2021 17:58:24 -0800 Subject: [PATCH] Always clip buffer points when clipping display points Co-Authored-By: Nathan Sobo --- crates/editor/src/display_map/block_map.rs | 18 +++++++----------- crates/editor/src/display_map/fold_map.rs | 6 +----- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index be4ac30616..d0a9103af3 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -598,17 +598,13 @@ impl BlockSnapshot { } let output_start = Point::new(output_start_row.0, 0); - if point.0 > output_start { - let output_overshoot = point.0 - output_start; - let input_start = Point::new(input_start_row.0, 0); - let input_point = self - .wrap_snapshot - .clip_point(WrapPoint(input_start + output_overshoot), bias); - let input_overshoot = input_point.0 - input_start; - return BlockPoint(output_start + input_overshoot); - } else { - return BlockPoint(output_start); - } + let output_overshoot = point.0 - output_start; + let input_start = Point::new(input_start_row.0, 0); + let input_point = self + .wrap_snapshot + .clip_point(WrapPoint(input_start + output_overshoot), bias); + let input_overshoot = input_point.0 - input_start; + return BlockPoint(output_start + input_overshoot); } else if search_left { cursor.prev(&()); } else { diff --git a/crates/editor/src/display_map/fold_map.rs b/crates/editor/src/display_map/fold_map.rs index 13e82fe942..74d2b3851f 100644 --- a/crates/editor/src/display_map/fold_map.rs +++ b/crates/editor/src/display_map/fold_map.rs @@ -691,11 +691,7 @@ impl FoldSnapshot { let buffer_position = cursor.start().1 + overshoot; let clipped_buffer_position = self.buffer_snapshot.clip_point(buffer_position, bias); - FoldPoint::new( - point.row(), - ((point.column() as i32) + clipped_buffer_position.column as i32 - - buffer_position.column as i32) as u32, - ) + FoldPoint(cursor.start().0 .0 + (clipped_buffer_position - cursor.start().1)) } } else { FoldPoint(self.transforms.summary().output.lines)