mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
Fix excess missed markers in non-Latin text
This commit is contained in:
parent
0f86c9fd11
commit
0be31b1b17
1 changed files with 10 additions and 1 deletions
|
@ -72,7 +72,7 @@ impl DiffContext {
|
||||||
}
|
}
|
||||||
"insert" => {
|
"insert" => {
|
||||||
let expected_str = self.slice_expected(&opcode);
|
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));
|
expected.push(DiffToken::missing(expected_str));
|
||||||
}
|
}
|
||||||
"replace" => {
|
"replace" => {
|
||||||
|
@ -248,6 +248,15 @@ mod test {
|
||||||
assert_eq!(ctx.to_tokens().provided, &[good("1"), missing("-"),]);
|
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]
|
#[test]
|
||||||
fn handles_certain_unicode_as_expected() {
|
fn handles_certain_unicode_as_expected() {
|
||||||
// this was not parsed as expected with dissimilar 1.0.4
|
// this was not parsed as expected with dissimilar 1.0.4
|
||||||
|
|
Loading…
Reference in a new issue