diff --git a/rslib/src/typeanswer.rs b/rslib/src/typeanswer.rs index a0cb08ded..1a95258b6 100644 --- a/rslib/src/typeanswer.rs +++ b/rslib/src/typeanswer.rs @@ -72,7 +72,7 @@ impl DiffContext { } "insert" => { let expected_str = self.slice_expected(&opcode); - provided.push(DiffToken::missing("-".repeat(expected_str.len()))); + provided.push(DiffToken::missing("-".repeat(expected_str.chars().count()))); expected.push(DiffToken::missing(expected_str)); } "replace" => { @@ -248,6 +248,15 @@ mod test { assert_eq!(ctx.to_tokens().provided, &[good("1"), missing("-"),]); } + #[test] + fn missed_chars_counted_correctly() { + let ctx = DiffContext::new("нос", "нс"); + assert_eq!( + ctx.to_tokens().provided, + &[good("н"), missing("-"), good("с")] + ); + } + #[test] fn handles_certain_unicode_as_expected() { // this was not parsed as expected with dissimilar 1.0.4