(&self, inode: Inode, root: [u64; 3], out: &mut RenderOutput<'_>)
| 1442 | } |
| 1443 | |
| 1444 | fn render_spans(&self, inode: Inode, root: [u64; 3], out: &mut RenderOutput<'_>) -> Result<()> { |
| 1445 | let mut active = BTreeSet::new(); |
| 1446 | active.insert(root); |
| 1447 | let mut stack = vec![self.frame(inode, root)?]; |
| 1448 | while let Some(frame) = stack.last_mut() { |
| 1449 | if frame.next == frame.edits.len() { |
| 1450 | append_visible(frame, frame.cursor, frame.end - frame.start, out); |
| 1451 | active.remove(&frame.span); |
| 1452 | stack.pop(); |
| 1453 | continue; |
| 1454 | } |
| 1455 | let [lo, hi, author, insert_start, insert_end] = frame.edits[frame.next]; |
| 1456 | frame.next += 1; |
| 1457 | let (lo, hi) = (usize::try_from(lo)?, usize::try_from(hi)?); |
| 1458 | ensure!( |
| 1459 | lo <= hi && hi <= frame.end - frame.start, |
| 1460 | "invalid stored range" |
| 1461 | ); |
| 1462 | let interior_gap = if lo < frame.cursor && lo == hi { |
| 1463 | match frame.covered { |
| 1464 | Some((cover_start, cover_end, cover_author)) |
| 1465 | if cover_start < lo && lo < cover_end && cover_author != author => |
| 1466 | { |
| 1467 | self.depends_on(cover_author, author)? |
| 1468 | } |
| 1469 | _ => false, |
| 1470 | } |
| 1471 | } else { |
| 1472 | false |
| 1473 | }; |
| 1474 | ensure!( |
| 1475 | lo >= frame.cursor || interior_gap, |
| 1476 | "unsupported overlapping or ambiguous edits" |
| 1477 | ); |
| 1478 | if let Some((p_lo, p_hi, p_author)) = frame.previous { |
| 1479 | let touches_gap = lo == p_hi && (lo == hi || p_lo == p_hi); |
| 1480 | let distinct_ranges = (p_lo == p_hi) != (lo == hi); |
| 1481 | let causal_touch = if touches_gap && distinct_ranges && author != p_author { |
| 1482 | self.depends_on(author, p_author)? || self.depends_on(p_author, author)? |
| 1483 | } else if touches_gap && lo == hi && p_lo == p_hi && author != p_author { |
| 1484 | self.depends_on(p_author, author)? |
| 1485 | } else { |
| 1486 | false |
| 1487 | }; |
| 1488 | if (lo < p_hi && !interior_gap) || (touches_gap && !causal_touch) { |
| 1489 | bail!("unsupported overlapping or ambiguous edits"); |
| 1490 | } |
| 1491 | } |
| 1492 | if !interior_gap { |
| 1493 | append_visible(frame, frame.cursor, lo, out); |
| 1494 | frame.cursor = hi; |
| 1495 | } |
| 1496 | if lo < hi { |
| 1497 | frame.covered = Some((lo, hi, author)); |
| 1498 | } |
| 1499 | frame.previous = Some((lo, hi, author)); |
| 1500 | if insert_start < insert_end { |
| 1501 | let child = [author, insert_start, insert_end]; |
no test coverage detected