diff --git a/CHANGELOG.md b/CHANGELOG.md index e4006fe..421268b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to similar are documented here. +## 1.2.0 + +* Make the unicode feature optional for inline diffing. + ## 1.1.0 * More generic lifetimes for `iter_changes` and `iter_inline_changes`. diff --git a/Cargo.toml b/Cargo.toml index be135cf..b990bab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ all-features = true [features] default = ["text"] text = [] -inline = ["unicode"] +inline = ["text"] # this annoyingly currently also turns on bstr and not just bstr/unicode # unclear if this is fixable diff --git a/src/text/inline.rs b/src/text/inline.rs index 0b368f3..cfedd21 100644 --- a/src/text/inline.rs +++ b/src/text/inline.rs @@ -18,7 +18,17 @@ impl<'bufs, 's, T: DiffableStr + ?Sized> MultiLookup<'bufs, 's, T> { let mut seqs = Vec::new(); for (string_idx, string) in strings.iter().enumerate() { let mut offset = 0; - for word in string.tokenize_unicode_words() { + let iter = { + #[cfg(feature = "unicode")] + { + string.tokenize_unicode_words() + } + #[cfg(not(feature = "unicode"))] + { + string.tokenize_words() + } + }; + for word in iter { seqs.push((word, string_idx, offset)); offset += word.len(); } diff --git a/src/text/mod.rs b/src/text/mod.rs index 9b66c58..69c41f4 100644 --- a/src/text/mod.rs +++ b/src/text/mod.rs @@ -485,6 +485,12 @@ impl<'old, 'new, 'bufs, T: DiffableStr + ?Sized + 'old + 'new> TextDiff<'old, 'n /// level diff on adjacent line replacements. The exact behavior of /// this function with regards to how it detects those inline changes /// is currently not defined and will likely change over time. + /// + /// As of similar 1.2.0 the behavior of this function changes depending on + /// if the `unicode` feature is enabled or not. It will prefer unicode word + /// splitting over word splitting depending on the feature flag. + /// + /// Requires the `inline` feature. #[cfg(feature = "inline")] pub fn iter_inline_changes<'x, 'slf>( &'slf self,