Skip to content

index out of range in apply_patch #2

@amitu

Description

@amitu
fn main() {
    applier("todo:\n- one", "todo:\n- one\n- two", "todo:\n- zero\n- one");
}

fn applier(base: &str, local: &str, remote: &str) {
    let mut dmp = diff_match_patch::Dmp::new();
    println!("------------------------- applier -------------------------");
    println!("========================= base =============================\n{}", base);
    println!("======================== local  ============================\n{}", local);
    println!("======================== remote ============================\n{}", remote);
    let mut patches = dmp.patch_make1(base, local);
    let (merged, conflicts) = dmp.patch_apply(&mut patches, remote);
    let merged = merged.into_iter().collect::<String>();
    let conflicts = conflicts.iter().filter(|v| **v).collect::<Vec<_>>().len() == 0;
    if conflicts {
        println!("{}\n====================== conflicted ==========================", merged);
    } else {
        println!("{}\n======================== merged ============================", merged);
    }
}

Exceptions at:

18: diff_match_patch::dmp::Dmp::patch_apply
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/diff_match_patch-0.1.0/src/dmp.rs:2318

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions