summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-06-26 14:52:55 -0400
committerDan Davison <dandavison7@gmail.com>2020-06-26 14:52:55 -0400
commitb83cee3707159c4b6bc0c5070a84d78f73017578 (patch)
tree1fe24dd058174a0b52291666b639294bfcbba0d7
parent8c1ed7b2dad3b83196ab9272174d6452b6fc75f2 (diff)
Bugfix: change op-coalescing algorithm when inferring edits
(No test coverage)
-rw-r--r--src/edits.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/edits.rs b/src/edits.rs
index 9b433ff5..b5ac232e 100644
--- a/src/edits.rs
+++ b/src/edits.rs
@@ -124,6 +124,7 @@ fn annotate<'a, Annotation>(
) -> (Vec<(Annotation, &'a str)>, Vec<(Annotation, &'a str)>, f64)
where
Annotation: Copy,
+ Annotation: PartialEq,
{
let mut annotated_minus_line = Vec::new();
let mut annotated_plus_line = Vec::new();
@@ -188,8 +189,11 @@ where
let n_d = distance_contribution(minus_section);
d_denom += n_d;
let is_space = minus_section.trim().is_empty();
+ let coalesce_space_with_previous = is_space
+ && ((minus_op_prev == deletion && plus_op_prev == insertion)
+ || (minus_op_prev == noop_deletion && plus_op_prev == noop_insertion));
annotated_minus_line.push((
- if is_space {
+ if coalesce_space_with_previous {
minus_op_prev
} else {
noop_deletion
@@ -197,7 +201,7 @@ where
minus_section,
));
annotated_plus_line.push((
- if is_space {
+ if coalesce_space_with_previous {
plus_op_prev
} else {
noop_insertion