mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-03 08:54:04 +00:00
Correctly report line boundaries when a map contains both folds and wraps
This fixes the randomized test failures that were occurring on main.
This commit is contained in:
parent
1a53d5b7ba
commit
0742640b39
2 changed files with 8 additions and 4 deletions
|
@ -199,7 +199,10 @@ impl DisplaySnapshot {
|
||||||
|
|
||||||
pub fn prev_line_boundary(&self, mut point: Point) -> (Point, DisplayPoint) {
|
pub fn prev_line_boundary(&self, mut point: Point) -> (Point, DisplayPoint) {
|
||||||
loop {
|
loop {
|
||||||
point.column = 0;
|
let mut fold_point = point.to_fold_point(&self.folds_snapshot, Bias::Left);
|
||||||
|
*fold_point.column_mut() = 0;
|
||||||
|
point = fold_point.to_buffer_point(&self.folds_snapshot);
|
||||||
|
|
||||||
let mut display_point = self.point_to_display_point(point, Bias::Left);
|
let mut display_point = self.point_to_display_point(point, Bias::Left);
|
||||||
*display_point.column_mut() = 0;
|
*display_point.column_mut() = 0;
|
||||||
let next_point = self.display_point_to_point(display_point, Bias::Left);
|
let next_point = self.display_point_to_point(display_point, Bias::Left);
|
||||||
|
@ -212,7 +215,10 @@ impl DisplaySnapshot {
|
||||||
|
|
||||||
pub fn next_line_boundary(&self, mut point: Point) -> (Point, DisplayPoint) {
|
pub fn next_line_boundary(&self, mut point: Point) -> (Point, DisplayPoint) {
|
||||||
loop {
|
loop {
|
||||||
point.column = self.buffer_snapshot.line_len(point.row);
|
let mut fold_point = point.to_fold_point(&self.folds_snapshot, Bias::Right);
|
||||||
|
*fold_point.column_mut() = self.folds_snapshot.line_len(fold_point.row());
|
||||||
|
point = fold_point.to_buffer_point(&self.folds_snapshot);
|
||||||
|
|
||||||
let mut display_point = self.point_to_display_point(point, Bias::Right);
|
let mut display_point = self.point_to_display_point(point, Bias::Right);
|
||||||
*display_point.column_mut() = self.line_len(display_point.row());
|
*display_point.column_mut() = self.line_len(display_point.row());
|
||||||
let next_point = self.display_point_to_point(display_point, Bias::Right);
|
let next_point = self.display_point_to_point(display_point, Bias::Right);
|
||||||
|
|
|
@ -37,7 +37,6 @@ impl FoldPoint {
|
||||||
&mut self.0.row
|
&mut self.0.row
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub fn column_mut(&mut self) -> &mut u32 {
|
pub fn column_mut(&mut self) -> &mut u32 {
|
||||||
&mut self.0.column
|
&mut self.0.column
|
||||||
}
|
}
|
||||||
|
@ -549,7 +548,6 @@ impl FoldSnapshot {
|
||||||
FoldOffset(self.transforms.summary().output.bytes)
|
FoldOffset(self.transforms.summary().output.bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub fn line_len(&self, row: u32) -> u32 {
|
pub fn line_len(&self, row: u32) -> u32 {
|
||||||
let line_start = FoldPoint::new(row, 0).to_offset(self).0;
|
let line_start = FoldPoint::new(row, 0).to_offset(self).0;
|
||||||
let line_end = if row >= self.max_point().row() {
|
let line_end = if row >= self.max_point().row() {
|
||||||
|
|
Loading…
Reference in a new issue