Adjust all operation offsets by adding to the positions. This is used after stripping common prefixes to restore correct positions.
(&mut self, offset: usize)
| 503 | /// |
| 504 | /// This is used after stripping common prefixes to restore correct positions. |
| 505 | pub(crate) fn adjust_offsets(&mut self, offset: usize) { |
| 506 | for op in &mut self.ops { |
| 507 | match op { |
| 508 | DiffOp::Equal { |
| 509 | old_pos, new_pos, .. |
| 510 | } => { |
| 511 | *old_pos += offset; |
| 512 | *new_pos += offset; |
| 513 | } |
| 514 | DiffOp::Insert { |
| 515 | old_pos, new_pos, .. |
| 516 | } => { |
| 517 | *old_pos += offset; |
| 518 | *new_pos += offset; |
| 519 | } |
| 520 | DiffOp::Delete { |
| 521 | old_pos, new_pos, .. |
| 522 | } => { |
| 523 | *old_pos += offset; |
| 524 | *new_pos += offset; |
| 525 | } |
| 526 | DiffOp::Replace { |
| 527 | old_pos, new_pos, .. |
| 528 | } => { |
| 529 | *old_pos += offset; |
| 530 | *new_pos += offset; |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | /// Prepend an Equal operation at the start. |
| 537 | pub(crate) fn prepend_equal(&mut self, old_pos: usize, len: usize) { |
no outgoing calls