From a40d93e26cb3eeb1f2df14d029edfe11e31d57c3 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Sun, 9 Oct 2022 23:48:21 -0700 Subject: [PATCH] Show possible and desired results in tricky cases manual section --- manual/src/tricky_cases.md | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/manual/src/tricky_cases.md b/manual/src/tricky_cases.md index 521bf86b5..eee99cdd6 100644 --- a/manual/src/tricky_cases.md +++ b/manual/src/tricky_cases.md @@ -15,6 +15,8 @@ x (x) ``` +Possible result: (x) + Desired result: (x) This is tricky because `x` has changed its depth in the tree, but `x` @@ -35,6 +37,8 @@ expressions. [x] ``` +Desired result: (x) [x] + As with the wrapping case, we want to highlight the delimiters rather than the `x`. @@ -93,7 +97,7 @@ where a later pair of delimiters are chosen. ``` We want to highlight `[[foo]]` being moved inside the -parentheses. However, a naive syntax differ prefers consider a removal +parentheses. However, a naive syntax differ prefers to consider a removal of `()` in the before and an addition of `()` in the after to be more minimal diff. @@ -160,10 +164,23 @@ A B C D ``` -Ideally we'd prefer marking contiguous nodes as novel, so we highlight -`A B` rather than `B\nA`. From the perspective of a -longest-common-subsequence algorithm, these two choices are -equivalent. +Possible result: + +
A B
+A B
+C D
+
+ +Preferred result: + +
A B
+A B
+C D
+
+ +Ideally we'd prefer marking contiguous nodes as novel. From the +perspective of a longest-common-subsequence algorithm, these two +choices are equivalent. ## Sliders (Nested) @@ -175,8 +192,9 @@ old1(old2) old1(new1(old2)) ``` -Should this be old1(new1(old2)) or -old1(new1(old2))? +Possible result: old1(new1(old2)) + +Desired result: old1(new1(old2)) The correct answer depends on the language. Most languages want to prefer the inner delimiter, whereas Lisps and JSON prefer the outer @@ -208,6 +226,8 @@ function foo(x) { return x + 1; } function bar(y) { baz(y); } ``` +Possible result: function bar(y) { baz(y); } + In this example, we've deleted a function and written a completely different one. A tree-based diff could match up the `function` and the outer delimiters, resulting in a confusing display showing lots of