Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup edit groups after coalescing #259

Merged
merged 1 commit into from May 25, 2021
Merged

Cleanup edit groups after coalescing #259

merged 1 commit into from May 25, 2021

Commits on May 25, 2021

  1. Cleanup edit groups after coalescing

    Even with an optimal diffing algoritm, coalescing adjacent edit groups
    may cause the corresponding pair of strings for an edit group to have
    leading or trailing spans of equal elements.
    
    While this is technically a correct representation of a diff,
    it is a suboptimal outcome. As such, scan through all unequal groups and
    move leading/trailing equal spans to the preceding/succeeding equal group.
    
    Before this change:
        strings.Join({
          "org-4747474747474747,bucket-4242424242424242:m,tag1=a,tag2=aa",
      -   ",#=_value _value=2 ",
      +   " _value=2 ",
          `11 org-4747474747474747,bucket-4242424242424242:m,tag1=a,tag2=bb`,
      -   ",#=_value _value=2 2",
      +   " _value=2 2",
          `1  org-4747474747474747,bucket-4242424242424242:m,tag1=b,tag2=cc`,
      -   ",#=_value",
          ` _value=1 21 org-4747474747474747,bucket-4242424242424242:m,tag1`,
          "=a,tag2",
      -   "=dd,#=_value",
      +   "=dd",
          ` _value=3 31 org-4747474747474747,bucket-4242424242424242:m,tag1`,
      -   "=c,#=_value",
      +   "=c",
          ` _value=4 41 `,
        }, "")
    
    After this change:
        strings.Join({
          "org-4747474747474747,bucket-4242424242424242:m,tag1=a,tag2=aa",
      -   ",#=_value",
          ` _value=2 11 org-4747474747474747,bucket-4242424242424242:m,tag1`,
          "=a,tag2=bb",
      -   ",#=_value",
          ` _value=2 21 org-4747474747474747,bucket-4242424242424242:m,tag1`,
          "=b,tag2=cc",
      -   ",#=_value",
          ` _value=1 21 org-4747474747474747,bucket-4242424242424242:m,tag1`,
          "=a,tag2=dd",
      -   ",#=_value",
          ` _value=3 31 org-4747474747474747,bucket-4242424242424242:m,tag1`,
          "=c",
      -   ",#=_value",
          ` _value=4 41 `,
        }, "")
    dsnet committed May 25, 2021
    Copy the full SHA
    5b2e1eb View commit details
    Browse the repository at this point in the history