GithubHelp home page GithubHelp logo

diff-match-patch.rs's People

Contributors

ajitk avatar eshurakov avatar iamsaquib8 avatar jkuhlmann avatar snr2718 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

diff-match-patch.rs's Issues

Index out of range in diff_main

This test panics: thread 'test::reproduce_index_out_of_range' panicked at 'index 106 out of range for slice of length 105', src\libcore\slice\mod.rs:2583:5.

#[test]
fn reproduce_index_out_of_range() {
    let old = r#"Minus dicta et officiis. Molestias velit et quas doloremque et qui. Ratione natus saepe est aliquam quasi."#;
    let new = r#"?Minus dicta et officiis? Molestias velit et quas doloremque et qui. Ratione natus saepe est aliquam quasi. Nesciunt ab nihil minus harum facilis ut sit. Exercitationem at totam."#;
    Dmp::new().diff_main(old, new, true);
}

To fix it, remove + 1 from this line:

line = text[line_start as usize..=line_end as usize + 1].iter().collect();

index out of range in apply_patch

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

word mode not implemented.

The diff-match-patch rust library does not have word mode.
Word mode is a part of main diff-match-patch library which is used for word level diffing. dmp rust has character mode and line mode but no word mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.