19524: Flags choose which PCA components to plot.
[lightning.git] / hgvs / diff.go
index 7fe72d9d263d060b5811e8bb300f109e4bf65e6b..0858aebe489dcc5d1ec0a4622098bd7765427cf5 100644 (file)
@@ -250,19 +250,6 @@ func cleanup(in []diffmatchpatch.Diff) (out []diffmatchpatch.Diff) {
                        i++
                        continue
                }
-               // when diffmatchpatch says [delA, =X, delBX], we
-               // prefer [delAB, =X].
-               if i < len(in)-2 &&
-                       d.Type == diffmatchpatch.DiffDelete &&
-                       in[i+1].Type == diffmatchpatch.DiffEqual &&
-                       in[i+2].Type == diffmatchpatch.DiffDelete &&
-                       strings.HasSuffix(in[i+2].Text, in[i+1].Text) {
-                       out = append(out,
-                               diffmatchpatch.Diff{diffmatchpatch.DiffDelete, d.Text + in[i+2].Text[:len(in[i+2].Text)-len(in[i+1].Text)]},
-                               in[i+1])
-                       i += 2
-                       continue
-               }
                // [=AB,insCB,=D] => [=A,insBC,=BD]
                // and
                // [=AB,delCB,=D] => [=A,delBC,=BD]
@@ -271,7 +258,6 @@ func cleanup(in []diffmatchpatch.Diff) (out []diffmatchpatch.Diff) {
                        in[i+1].Type != diffmatchpatch.DiffEqual &&
                        in[i+2].Type == diffmatchpatch.DiffEqual &&
                        len(d.Text) > 0 && len(in[i+1].Text) > 0 &&
-                       d.Text[len(d.Text)-1] == in[i+1].Text[len(in[i+1].Text)-1] &&
                        !(i+3 < len(in) &&
                                // Except: leave deletion alone if an
                                // upcoming insertion will be moved up
@@ -283,6 +269,12 @@ func cleanup(in []diffmatchpatch.Diff) (out []diffmatchpatch.Diff) {
                                in[i+1].Type == diffmatchpatch.DiffDelete &&
                                in[i+3].Type == diffmatchpatch.DiffInsert &&
                                strings.HasSuffix(in[i+3].Text, in[i+2].Text)) {
+                       if i+3 < len(in) && in[i+1].Type == in[i+3].Type && strings.HasSuffix(in[i+3].Text, in[i+2].Text) {
+                               // [=AB,delC,=E,delDBE] => [=AB,delCEDB,=E,=]
+                               in[i+1], in[i+2], in[i+3] = diffmatchpatch.Diff{in[i+1].Type, in[i+1].Text + in[i+2].Text + in[i+3].Text[:len(in[i+3].Text)-len(in[i+2].Text)]},
+                                       diffmatchpatch.Diff{diffmatchpatch.DiffEqual, in[i+2].Text},
+                                       diffmatchpatch.Diff{diffmatchpatch.DiffEqual, ""}
+                       }
                        // Find x, length of common suffix B
                        x := 1
                        for ; x <= len(d.Text) && x <= len(in[i+1].Text); x++ {
@@ -297,6 +289,11 @@ func cleanup(in []diffmatchpatch.Diff) (out []diffmatchpatch.Diff) {
                                        in[i+1].Text[:len(in[i+1].Text)-x],
                                in[i+1].Text[len(in[i+1].Text)-x:]+in[i+2].Text
                }
+               // [=X,delAX] => [delXA,=X]
+               if i < len(in)-1 &&
+                       d.Type == diffmatchpatch.DiffEqual &&
+                       in[i+1].Type == diffmatchpatch.DiffDelete && false {
+               }
                out = append(out, d)
        }
        in, out = out, make([]diffmatchpatch.Diff, 0, len(in))