Successor to #27779 - in this PR I've applied changes manually, without futzing with if let lifetimes at all. Release Notes: - N/A
Showing the changes to crates/buffer_diff/src/buffer_diff.rs (1 of 162 files). Show all
Unified · Split
| @@ -433,79 +433,82 @@ impl BufferDiffInner { · 432 unmodified lines | ||
| 433 | 433 | |
| 434 | 434 | let max_point = buffer.max_point(); |
| 435 | 435 | let mut summaries = buffer.summaries_for_anchors_with_payload::<Point, _, _>(anchor_iter); |
| 436 | − iter::from_fn(move || loop { | |
| 437 | − let (start_point, (start_anchor, start_base)) = summaries.next()?; | |
| 438 | − let (mut end_point, (mut end_anchor, end_base)) = summaries.next()?; | |
| 439 | − | |
| 440 | − if !start_anchor.is_valid(buffer) { | |
| 441 | − continue; | |
| 442 | − } | |
| 443 | − | |
| 444 | − if end_point.column > 0 && end_point < max_point { | |
| 445 | − end_point.row += 1; | |
| 446 | − end_point.column = 0; | |
| 447 | − end_anchor = buffer.anchor_before(end_point); | |
| 448 | − } | |
| 449 | − | |
| 450 | − let mut secondary_status = DiffHunkSecondaryStatus::NoSecondaryHunk; | |
| 451 | − | |
| 452 | − let mut has_pending = false; | |
| 453 | − if start_anchor | |
| 454 | − .cmp(&pending_hunks_cursor.start().buffer_range.start, buffer) | |
| 455 | − .is_gt() | |
| 456 | − { | |
| 457 | − pending_hunks_cursor.seek_forward(&start_anchor, Bias::Left, buffer); | |
| 458 | − } | |
| 436 | + iter::from_fn(move || { | |
| 437 | + loop { | |
| 438 | + let (start_point, (start_anchor, start_base)) = summaries.next()?; | |
| 439 | + let (mut end_point, (mut end_anchor, end_base)) = summaries.next()?; | |
| 459 | 440 | |
| 460 | − if let Some(pending_hunk) = pending_hunks_cursor.item() { | |
| 461 | − let mut pending_range = pending_hunk.buffer_range.to_point(buffer); | |
| 462 | − if pending_range.end.column > 0 { | |
| 463 | − pending_range.end.row += 1; | |
| 464 | − pending_range.end.column = 0; | |
| 441 | + if !start_anchor.is_valid(buffer) { | |
| 442 | + continue; | |
| 465 | 443 | } |
| 466 | 444 | |
| 467 | − if pending_range == (start_point..end_point) { | |
| 468 | − if !buffer.has_edits_since_in_range( | |
| 469 | − &pending_hunk.buffer_version, | |
| 470 | − start_anchor..end_anchor, | |
| 471 | − ) { | |
| 472 | − has_pending = true; | |
| 473 | − secondary_status = pending_hunk.new_status; | |
| 474 | − } | |
| 445 | + if end_point.column > 0 && end_point < max_point { | |
| 446 | + end_point.row += 1; | |
| 447 | + end_point.column = 0; | |
| 448 | + end_anchor = buffer.anchor_before(end_point); | |
| 475 | 449 | } |
| 476 | − } | |
| 477 | 450 | |
| 478 | − if let (Some(secondary_cursor), false) = (secondary_cursor.as_mut(), has_pending) { | |
| 451 | + let mut secondary_status = DiffHunkSecondaryStatus::NoSecondaryHunk; | |
| 452 | + | |
| 453 | + let mut has_pending = false; | |
| 479 | 454 | if start_anchor |
| 480 | − .cmp(&secondary_cursor.start().buffer_range.start, buffer) | |
| 455 | + .cmp(&pending_hunks_cursor.start().buffer_range.start, buffer) | |
| 481 | 456 | .is_gt() |
| 482 | 457 | { |
| 483 | − secondary_cursor.seek_forward(&start_anchor, Bias::Left, buffer); | |
| 458 | + pending_hunks_cursor.seek_forward(&start_anchor, Bias::Left, buffer); | |
| 484 | 459 | } |
| 485 | 460 | |
| 486 | − if let Some(secondary_hunk) = secondary_cursor.item() { | |
| 487 | − let mut secondary_range = secondary_hunk.buffer_range.to_point(buffer); | |
| 488 | − if secondary_range.end.column > 0 { | |
| 489 | − secondary_range.end.row += 1; | |
| 490 | − secondary_range.end.column = 0; | |
| 461 | + if let Some(pending_hunk) = pending_hunks_cursor.item() { | |
| 462 | + let mut pending_range = pending_hunk.buffer_range.to_point(buffer); | |
| 463 | + if pending_range.end.column > 0 { | |
| 464 | + pending_range.end.row += 1; | |
| 465 | + pending_range.end.column = 0; | |
| 466 | + } | |
| 467 | + | |
| 468 | + if pending_range == (start_point..end_point) { | |
| 469 | + if !buffer.has_edits_since_in_range( | |
| 470 | + &pending_hunk.buffer_version, | |
| 471 | + start_anchor..end_anchor, | |
| 472 | + ) { | |
| 473 | + has_pending = true; | |
| 474 | + secondary_status = pending_hunk.new_status; | |
| 475 | + } | |
| 491 | 476 | } |
| 492 | − if secondary_range.is_empty() && secondary_hunk.diff_base_byte_range.is_empty() | |
| 477 | + } | |
| 478 | + | |
| 479 | + if let (Some(secondary_cursor), false) = (secondary_cursor.as_mut(), has_pending) { | |
| 480 | + if start_anchor | |
| 481 | + .cmp(&secondary_cursor.start().buffer_range.start, buffer) | |
| 482 | + .is_gt() | |
| 493 | 483 | { |
| 494 | − // ignore | |
| 495 | − } else if secondary_range == (start_point..end_point) { | |
| 496 | − secondary_status = DiffHunkSecondaryStatus::HasSecondaryHunk; | |
| 497 | − } else if secondary_range.start <= end_point { | |
| 498 | − secondary_status = DiffHunkSecondaryStatus::OverlapsWithSecondaryHunk; | |
| 484 | + secondary_cursor.seek_forward(&start_anchor, Bias::Left, buffer); | |
| 485 | + } | |
| 486 | + | |
| 487 | + if let Some(secondary_hunk) = secondary_cursor.item() { | |
| 488 | + let mut secondary_range = secondary_hunk.buffer_range.to_point(buffer); | |
| 489 | + if secondary_range.end.column > 0 { | |
| 490 | + secondary_range.end.row += 1; | |
| 491 | + secondary_range.end.column = 0; | |
| 492 | + } | |
| 493 | + if secondary_range.is_empty() | |
| 494 | + && secondary_hunk.diff_base_byte_range.is_empty() | |
| 495 | + { | |
| 496 | + // ignore | |
| 497 | + } else if secondary_range == (start_point..end_point) { | |
| 498 | + secondary_status = DiffHunkSecondaryStatus::HasSecondaryHunk; | |
| 499 | + } else if secondary_range.start <= end_point { | |
| 500 | + secondary_status = DiffHunkSecondaryStatus::OverlapsWithSecondaryHunk; | |
| 501 | + } | |
| 499 | 502 | } |
| 500 | 503 | } |
| 501 | − } | |
| 502 | 504 | |
| 503 | − return Some(DiffHunk { | |
| 504 | − range: start_point..end_point, | |
| 505 | − diff_base_byte_range: start_base..end_base, | |
| 506 | − buffer_range: start_anchor..end_anchor, | |
| 507 | − secondary_status, | |
| 508 | − }); | |
| 505 | + return Some(DiffHunk { | |
| 506 | + range: start_point..end_point, | |
| 507 | + diff_base_byte_range: start_base..end_base, | |
| 508 | + buffer_range: start_anchor..end_anchor, | |
| 509 | + secondary_status, | |
| 510 | + }); | |
| 511 | + } | |
| 509 | 512 | }) |
| 510 | 513 | } |
| 511 | 514 | |
| @@ -776,7 +779,7 @@ impl BufferDiff { · 264 unmodified lines | ||
| 776 | 779 | language: Option<Arc<Language>>, |
| 777 | 780 | language_registry: Option<Arc<LanguageRegistry>>, |
| 778 | 781 | cx: &mut App, |
| 779 | − ) -> impl Future<Output = BufferDiffInner> { | |
| 782 | + ) -> impl Future<Output = BufferDiffInner> + use<> { | |
| 780 | 783 | let base_text_pair; |
| 781 | 784 | let base_text_exists; |
| 782 | 785 | let base_text_snapshot; |
| @@ -818,7 +821,7 @@ impl BufferDiff { · 35 unmodified lines | ||
| 818 | 821 | base_text: Option<Arc<String>>, |
| 819 | 822 | base_text_snapshot: language::BufferSnapshot, |
| 820 | 823 | cx: &App, |
| 821 | − ) -> impl Future<Output = BufferDiffInner> { | |
| 824 | + ) -> impl Future<Output = BufferDiffInner> + use<> { | |
| 822 | 825 | let base_text_exists = base_text.is_some(); |
| 823 | 826 | let base_text_pair = base_text.map(|text| (text, base_text_snapshot.as_rope().clone())); |
| 824 | 827 | cx.background_spawn(async move { |
| @@ -2071,7 +2074,7 @@ mod tests { · 1246 unmodified lines | ||
| 2071 | 2074 | ) |
| 2072 | 2075 | }); |
| 2073 | 2076 | let working_copy = working_copy.read_with(cx, |working_copy, _| working_copy.snapshot()); |
| 2074 | − let mut index_text = if rng.gen() { | |
| 2077 | + let mut index_text = if rng.r#gen() { | |
| 2075 | 2078 | Rope::from(head_text.as_str()) |
| 2076 | 2079 | } else { |
| 2077 | 2080 | working_copy.as_rope().clone() |