Compute an inline diff with custom configuration. # Arguments `old_line` - The original line content `new_line` - The modified line content `config` - Word diff configuration # Returns An `InlineDiff` containing highlighted hunks for both lines.
(
old_line: &'a [u8],
new_line: &'a [u8],
config: &WordDiffConfig,
)
| 614 | /// |
| 615 | /// An `InlineDiff` containing highlighted hunks for both lines. |
| 616 | pub fn compute_inline_diff_with_config<'a>( |
| 617 | old_line: &'a [u8], |
| 618 | new_line: &'a [u8], |
| 619 | config: &WordDiffConfig, |
| 620 | ) -> InlineDiff<'a> { |
| 621 | // Handle empty cases |
| 622 | if old_line.is_empty() && new_line.is_empty() { |
| 623 | return InlineDiff::unchanged(old_line, new_line); |
| 624 | } |
| 625 | |
| 626 | if old_line.is_empty() { |
| 627 | return InlineDiff::all_inserted(old_line, new_line); |
| 628 | } |
| 629 | |
| 630 | if new_line.is_empty() { |
| 631 | return InlineDiff::all_deleted(old_line, new_line); |
| 632 | } |
| 633 | |
| 634 | // Quick check for identical content |
| 635 | if old_line == new_line { |
| 636 | return InlineDiff::unchanged(old_line, new_line); |
| 637 | } |
| 638 | |
| 639 | // Compute word-level diff |
| 640 | let word_result = super::word::word_diff_with_config(old_line, new_line, config); |
| 641 | |
| 642 | // Convert word diff to inline hunks |
| 643 | convert_word_diff_to_hunks(old_line, new_line, &word_result) |
| 644 | } |
| 645 | |
| 646 | /// Convert a word diff result to inline hunks. |
| 647 | fn convert_word_diff_to_hunks<'a>( |
no test coverage detected