distill-io / diff-match-patch.rs Goto Github PK
View Code? Open in Web Editor NEWdiff-match-patch for rust
diff-match-patch for rust
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:
I'm curious if this is in production and if it is working well at scale
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
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.