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

Diff cleanup semantic not working as expected #104

Open
ash-lionell opened this issue Oct 26, 2020 · 2 comments
Open

Diff cleanup semantic not working as expected #104

ash-lionell opened this issue Oct 26, 2020 · 2 comments

Comments

@ash-lionell
Copy link

For the following input:

This text is bold, underlined, italicized, Arial and has a different color and size.

This text is not bold, not underlined, not italicized, Calibri and has the same color and size.

The diff cleanup returns:

[Diff(EQUAL,"This text is "), Diff(DELETE,"not "), Diff(EQUAL,"bold,"), Diff(DELETE," not"), Diff(EQUAL," underlined,"), Diff(DELETE," not"), Diff(EQUAL," italicized, "), Diff(DELETE,"Calibri"), Diff(INSERT,"Arial"), Diff(EQUAL," and has "), Diff(DELETE,"the same"), Diff(INSERT,"a different"), Diff(EQUAL," color and size.")]

As expected.

But for some other texts like:

This is a sample text.

This is a sample test.

The diff cleanup returns:

[Diff(EQUAL,"This is a sample te"), Diff(DELETE,"x"), Diff(INSERT,"s"), Diff(EQUAL,"t.")]

Whereas, it should've cleaned up the last word text/test and shown it as one DELETE/INSERT operation.

Observed this behavior in both Java and Javascript bindings.

@mark1bean
Copy link

I can confirm this issue. Here's my example in javascript:

var text1 = 'I ate a red apple.';
var text2 = 'I ate a green apple.';

var dmp = new diff_match_patch();
var diffs = dmp.diff_main(text1, text2);
dmp.diff_cleanupSemantic(diffs);

Result:

EQUAL	"I ate a "
INSERT	"g"
EQUAL	"re"
DELETE	"d"
INSERT	"en"
EQUAL	" apple."

Expected result:

EQUAL	"I ate a "
INSERT	"green"
DELETE	"red"
EQUAL	" apple."

@ttpho
Copy link

ttpho commented Mar 24, 2023

@NeilFraser Please support this issue. 🙇🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants