A multi-line entry: `lines` chained inserts plus `tokens` leaves per line, with `after` references that must shift with the branch base.
(path: &str, lines: usize, tokens: usize)
| 338 | /// A multi-line entry: `lines` chained inserts plus `tokens` leaves per line, |
| 339 | /// with `after` references that must shift with the branch base. |
| 340 | fn multi_line_entry(path: &str, lines: usize, tokens: usize) -> FileOps { |
| 341 | let mut ops = FileOps::create(CrdtTrunkId::ROOT, path.to_string(), None); |
| 342 | for line in 0..lines { |
| 343 | let after = if line == 0 { |
| 344 | None |
| 345 | } else { |
| 346 | Some(CrdtBranchId::new(NodeId::ROOT, (line - 1) as u32)) |
| 347 | }; |
| 348 | let mut content = Vec::with_capacity(tokens); |
| 349 | for token in 0..tokens { |
| 350 | content.push(LeafOp::Insert { |
| 351 | after: if token == 0 { |
| 352 | None |
| 353 | } else { |
| 354 | Some(LeafId::new(NodeId::ROOT, (token - 1) as u32)) |
| 355 | }, |
| 356 | kind: if token % 2 == 0 { |
| 357 | TokenKind::Word |
| 358 | } else { |
| 359 | TokenKind::Whitespace |
| 360 | }, |
| 361 | content: format!("t{token}").into_bytes(), |
| 362 | }); |
| 363 | } |
| 364 | ops.add_line_op(crate::change::LineOps::new( |
| 365 | CrdtBranchId::new(NodeId::ROOT, line as u32), |
| 366 | BranchOp::Insert { after, content }, |
| 367 | )); |
| 368 | } |
| 369 | ops |
| 370 | } |
| 371 | |
| 372 | #[test] |
| 373 | fn add_file_ops_placeholder_namespace_advances_linearly_for_one_line_files() { |
no test coverage detected