Fix utf8 handling
This commit is contained in:
parent
3abc45cb86
commit
6d1d5ca3bc
1 changed files with 24 additions and 1 deletions
|
|
@ -329,7 +329,12 @@ where
|
|||
order,
|
||||
..
|
||||
} => {
|
||||
let deleted = self.text[*order..*order + *deleted_character_count].to_string();
|
||||
let deleted: String = self
|
||||
.text
|
||||
.chars()
|
||||
.skip(*order)
|
||||
.take(*deleted_character_count)
|
||||
.collect();
|
||||
match side {
|
||||
Side::Left => {
|
||||
history.push(SpanWithHistory::new(deleted, History::RemovedFromLeft));
|
||||
|
|
@ -592,6 +597,24 @@ mod tests {
|
|||
assert_eq!(serialized, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_apply_with_history_utf8() {
|
||||
let parent = "こんにちは世界"; // "Hello World" in Japanese (7 chars, 21 bytes)
|
||||
let left = "こんにちは宇宙"; // Changed 世界 to 宇宙
|
||||
let right = parent;
|
||||
|
||||
let result = crate::reconcile(
|
||||
parent,
|
||||
&left.into(),
|
||||
&right.into(),
|
||||
&*BuiltinTokenizer::Word,
|
||||
);
|
||||
|
||||
let history = result.apply_with_history();
|
||||
assert!(!history.is_empty());
|
||||
assert_eq!(result.apply().text(), "こんにちは宇宙");
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
#[test]
|
||||
fn test_changes_serialization() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue