MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / compute_inline_diff_with_config

Function compute_inline_diff_with_config

atomic-core/src/diff/inline.rs:616–644  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

614///
615/// An `InlineDiff` containing highlighted hunks for both lines.
616pub 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.
647fn convert_word_diff_to_hunks<'a>(

Callers 1

compute_inline_diffFunction · 0.85

Calls 3

word_diff_with_configFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected