diff --git a/CHANGELOG.md b/CHANGELOG.md index f221e5af2..f4287b1f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ Difftastic will now prefer matching up comments that are similar Contiguous syntax logic now considers close delimiter positions, so `[ \n ];` now treats the `;` atom as contiguous. +Fixed an issue where diffs would prefer prefer a low depth change on a +delimiter over a delimiter that gave contiguous changes. + ### Display Display width calculations are now based on the longest line visible diff --git a/src/dijkstra.rs b/src/dijkstra.rs index 48e2b0e94..23cd81601 100644 --- a/src/dijkstra.rs +++ b/src/dijkstra.rs @@ -156,14 +156,20 @@ impl Edge { if *contiguous { 300 } else { - 301 + // This needs to be more than 40 greater than the + // contiguous case. Otherwise, we end up choosing + // a badly positioned unchanged elimiter just + // because it has a better depth difference. + // + // TODO: write a test for this case. + 350 } } NovelDelimiterLHS { contiguous } | NovelDelimiterRHS { contiguous } => { if *contiguous { 300 } else { - 301 + 350 } }