php-diff icon indicating copy to clipboard operation
php-diff copied to clipboard

Long text diff

Open kouroshfar opened this issue 1 year ago • 3 comments

Hi and thanks for your great library. I have a problem with long texts comparisons. I have these configs:

// the Diff class options
$differOptions = [
    'context' => Differ::CONTEXT_ALL,
    'ignoreCase' => false,
    'ignoreLineEnding' => false,
    'ignoreWhitespace' => false,
    'lengthLimit' => 200000,
    'fullContextIfIdentical' => false,
];
// the renderer class options
$rendererOptions = [
    'detailLevel' => 'word',
    'language' => 'eng',
    'lineNumbers' => false,
    'separateBlock' => false,
    'showHeader' => false,
    'spacesToNbsp' => false,
    'tabSize' => 4,
    'mergeThreshold' => 0.8,
    'cliColorization' => RendererConstant::CLI_COLOR_AUTO,
    'outputTagAsString' => false,
    'jsonEncodeFlags' => \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE,
    'wordGlues' => [' ', '-'],
    'resultForIdenticals' => null,
    'wrapperClasses' => ['diff-wrapper '],
];
$rendererName = 'Combined';
$result = DiffHelper::calculate($old, $new, $rendererName, $differOptions, $rendererOptions);

And I wanted to compare these 2 texts:

New.txt Old.txt

When the context set to Differ::CONTEXT_ALL it will not show the full text on the result. I need to see the removed sentences and added sentences and also modified sentences too.

I need to have a result like this. Can you help me? I've attached my result at the end of the issue too.

screenshot screenshot

kouroshfar avatar Jul 19 '24 07:07 kouroshfar

When the context set to Differ::CONTEXT_ALL it will not show the full text on the result.

I don't notice anything unexpected with your options and sources.

Snipaste_2024-07-19_22-18-43

jfcherng avatar Jul 19 '24 14:07 jfcherng

Thanks for your reply. If you see my latest uploaded image, i have the result same as you. But on the left column as you can see i have many sentences that they should show on the right column as a removed text (as we don't have them more), but we can't see.

screen

kouroshfar avatar Jul 19 '24 14:07 kouroshfar

But on the left column as you can see i have many sentences that they should show on the right column as a removed text (as we don't have them more), but we can't see.

That's not what you provided in old.txt / new.txt.

To save our time, use the demo example to provide results and point out what the issue is. I won't try anything other than the demo example.

jfcherng avatar Jul 19 '24 14:07 jfcherng