Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

confuse about diff-match-path compute results on microsoft TODO app, can somebody give some tips? #120

Open

Description

@initlifeinc

I try to understand how diff-match-patch works on Microsoft TODO app.

So i try to create a case about different copies on a base text , and use diff-match-patch to resolve to get a final result, and compared it with the result got from Microsoft TODO app.

The following is my case:
Here i define some names to indicate the case texts.
-----------------define begin-----------------------
BaseText
I am the very model of a cartoon individual,
My animation's comical, unusual, and whimsical,
I'm quite adept at funny gags, comedic theory I have read,
From wicked puns and stupid jokes to anvils that drop on your head.

TextA:
I am the very model of a modern Major-General,
I've information vegetable, animal, and mineral,
I know the kings of England, and I quote the fights historical,
From Marathon to Waterloo, in order categorical.

TextB:
I am the very model of a cartoon individual, xxxxx
My animation's comical, unusual, and whimsical,
I'm quite adept at funny gags, comedic theory I have read,
From wicked puns and stupid jokes to anvils that drop on your head.

FinalResultText:
I am the very model of a modern Major-Generxxx
My aniI'veformation vegetable, animal, and mineral,
I know the kings of England, and I quote the fights historical,
From Marathon to Waterloo, in order categorical.

------------------define end-----------------

The change timeline is:

  1. First UserA and UserB are all BaseText
  2. UserA change BaseText to TextA in online status, but UserB is offline status.
  3. After UserA finish change, UserB change his BaseText to TextB under offline status.
  4. UserB switch the network on, commit it changes to server.
  5. wait for a while, for Microsoft TODO App, both UserA and UserB change their texts to FinalResultText. But on this demo(https://neil.fraser.name/software/diff_match_patch/demos/patch.html), the result text is TextA.

I can understand that on patch demo, patch of UserB changes cannot patch on TextA, so the final result is TextA. But i cannot understand why Microsoft use DiffMatchPatch but the result is FinalResultText.

Any body known why it is?

Activity

  1. dmsnell commented on Sep 23, 2021

    @dmsnell

    It's not going to be easy to know what Microsoft is doing in their app without inspecting the code. As far as diff-match-patch is concerned though it should not apply patches that are unresolvable automatically. In this case, we cannot reconcile the differences without choosing which differences we want to preserve.

    It is possible to apply an invalid patch and it looks like that happened here. In the first line it looks like UserB's changes were applied first and then the patch submitted by UserA was applied over it. Line three seems to contradict this theory. Patches can specify ranges of text to keep, delete, or insert. They don't specify "change this old thing to this new thing" so if you apply them to the wrong text you will get gibberish.

  2. initlifeinc commented on Sep 26, 2021

    @initlifeinc
    Author

    Got it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions