From c0d1faae6340d1e7f2dde94f1e6a1c05507bb474 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Sun, 13 Mar 2022 15:35:53 -0700 Subject: [PATCH] Keep exploring the graph even when we find matched delimiters Previously we'd get tripped up by cases where choosing equal delimiters would be be considered the same as entering each delimiter separately, making diffs worse. Fixes #147 --- sample_files/change_outer_after.el | 1 + sample_files/change_outer_before.el | 1 + sample_files/compare.expected | 7 +++++-- src/graph.rs | 5 +++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 sample_files/change_outer_after.el create mode 100644 sample_files/change_outer_before.el diff --git a/sample_files/change_outer_after.el b/sample_files/change_outer_after.el new file mode 100644 index 000000000..0d17e3002 --- /dev/null +++ b/sample_files/change_outer_after.el @@ -0,0 +1 @@ +[(lhs) comma rhs] diff --git a/sample_files/change_outer_before.el b/sample_files/change_outer_before.el new file mode 100644 index 000000000..63b007fc4 --- /dev/null +++ b/sample_files/change_outer_before.el @@ -0,0 +1 @@ +(lhs comma rhs) diff --git a/sample_files/compare.expected b/sample_files/compare.expected index 0a00bc03d..4f9d39849 100644 --- a/sample_files/compare.expected +++ b/sample_files/compare.expected @@ -1,6 +1,9 @@ sample_files/bad_combine_before.rs sample_files/bad_combine_after.rs ffb31b7f11712d0e28a7f874bb7756c6 - +sample_files/change_outer_before.el sample_files/change_outer_after.el +1e144818ad54091b05e58e2c617add8f - + sample_files/clojure_before.clj sample_files/clojure_after.clj 8316bcd959ce706ac07011f6dc31c93a - @@ -77,10 +80,10 @@ sample_files/simple_before.txt sample_files/simple_after.txt 4b653ebe89321835c35722dd065cf6a2 - sample_files/slider_before.rs sample_files/slider_after.rs -9b21c5790773eaba1a83e92fe2b9b5a8 - +ab11d8dfc684921d85f49d3ec4dfeec4 - sample_files/slow_before.rs sample_files/slow_after.rs -07c6dda6ca91de93a0553f90060697d0 - +1f6176a6518e16eb8dfe32d7d81c63d9 - sample_files/small_before.js sample_files/small_after.js ee97a525a74be6dd18e959395d02265b - diff --git a/src/graph.rs b/src/graph.rs index aa412b689..b0ea71c3c 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -71,6 +71,11 @@ impl<'a> PartialEq for Vertex<'a> { // the graph size relative to tree depth. && self.lhs_parent_id == other.lhs_parent_id && self.rhs_parent_id == other.rhs_parent_id + // We do want to distinguish whether we can pop each side + // independently though. Without this, if we find a case + // where we can pop sides together, we don't consider the + // case where we get a better diff by popping each side + // separately. && self.can_pop_either == other.can_pop_either } }