Fix unit test for on-disk-changes to not rely on selection bias

This commit is contained in:
Max Brunsfeld 2021-10-28 16:17:07 -07:00
parent f3cd710f21
commit 9bc08e446b
2 changed files with 12 additions and 8 deletions

View file

@ -638,7 +638,10 @@ impl Buffer {
if selection.start.column == 0 { if selection.start.column == 0 {
let delta = Point::new( let delta = Point::new(
0, 0,
indent_columns.get(&selection.start.row).copied().unwrap_or(0), indent_columns
.get(&selection.start.row)
.copied()
.unwrap_or(0),
); );
if delta.column > 0 { if delta.column > 0 {
return Selection { return Selection {

View file

@ -3348,15 +3348,15 @@ mod tests {
.await .await
.unwrap(); .unwrap();
// Add a cursor at the start of each row. // Add a cursor on each row.
let selection_set_id = buffer.update(&mut cx, |buffer, cx| { let selection_set_id = buffer.update(&mut cx, |buffer, cx| {
assert!(!buffer.is_dirty()); assert!(!buffer.is_dirty());
buffer.add_selection_set( buffer.add_selection_set(
&(0..3) &(0..3)
.map(|row| Selection { .map(|row| Selection {
id: row as usize, id: row as usize,
start: Point::new(row, 0), start: Point::new(row, 1),
end: Point::new(row, 0), end: Point::new(row, 1),
reversed: false, reversed: false,
goal: SelectionGoal::None, goal: SelectionGoal::None,
}) })
@ -3378,7 +3378,7 @@ mod tests {
// contents are edited according to the diff between the old and new // contents are edited according to the diff between the old and new
// file contents. // file contents.
buffer buffer
.condition(&cx, |buffer, _| buffer.text() != initial_contents) .condition(&cx, |buffer, _| buffer.text() == new_contents)
.await; .await;
buffer.update(&mut cx, |buffer, _| { buffer.update(&mut cx, |buffer, _| {
@ -3386,8 +3386,9 @@ mod tests {
assert!(!buffer.is_dirty()); assert!(!buffer.is_dirty());
assert!(!buffer.has_conflict()); assert!(!buffer.has_conflict());
let set = buffer.selection_set(selection_set_id).unwrap(); let cursor_positions = buffer
let cursor_positions = set .selection_set(selection_set_id)
.unwrap()
.point_selections(&*buffer) .point_selections(&*buffer)
.map(|selection| { .map(|selection| {
assert_eq!(selection.start, selection.end); assert_eq!(selection.start, selection.end);
@ -3396,7 +3397,7 @@ mod tests {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
assert_eq!( assert_eq!(
cursor_positions, cursor_positions,
&[Point::new(1, 0), Point::new(3, 0), Point::new(4, 0),] [Point::new(1, 1), Point::new(3, 1), Point::new(4, 0)]
); );
}); });