Skip to content

Newlines-only diff are inconsistently reported #28

@elinorbgr

Description

@elinorbgr

Consider this example:

fn main() {
    let input = r#"
Foo
Bar


Baz

Bam


Meh
"#;

    let output = r#"
Foo
Bar

Baz
Bam

Meh"#;

    let changeset = Changeset::new(input, output, "\n");
    println!("distance = {}", changeset.distance);
    println!("{:#?}", changeset.diffs);
}

It outputs this:

distance = 4
[
    Same(
        "Foo\nBar\n\nBaz\nBam\n\nMeh\n"
    )
]

There is an inconsistency here, there is a distance of 4 yet the diff is only a single Same entry.

I would typically have expected the diff to be something like:

[
    Same("Foo\nBar\n"),
    Rem("\n"),
    Same("Baz\n"),
    Rem("\n"),
    Same("Bam\n"),
    Rem("\n"),
    Same("Meh"),
    Rem("\n")
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions