JBlond/php-diff

First or last x lines of text are shown even when there's no difference between the two compared texts.

Closed this issue · 8 comments

Hi
Thank you very much for this code that is very useful to me.
I would like to know if there is any method to know if there are no differences and thus not show anything or if it is possible to add it

As far as I'm aware most, if not all, renderers should produce either nothing or a string saying 'No differences found'.

To which renderer are you referring?

@DigiLive There shouldn't be any output. However, when I compare a.txt with a.txt in the example folder I get a difference.

@@ -32,3 +32,3 @@
     </body>
 </html>

I tired the orginal from chrisboulton/php-diff. There it isn't. I will track that tomorrow which commit caused that.

v1.15 doesn't have that issue. It came with v1.16
98d993e is the cause. in the sequence matcher

now line 610

is

if ($this->options['trimEqual'] || (!empty($group) && !(count($group) == 1 && $group[0][0] == 'equal'))) {

was

if (!empty($group) && !(count($group) == 1 && $group[0][0] == 'equal')) {

Agreeing there's a bug... It's a combo of option trimEqual and context of the SequenceMatcher class.
I think I've found where it goes wrong, but I need to verify some things because of the SequenceMatchers's complexity.

However, HTML Side by Side Diff, HTML Inline Diff and HTML Unified Diff will produce output string No differences found. when the bug is fixed. It's hard-coded in the HtmlArray class.
@JBlond Let me know if, and into what, you want this to be changed.

Related to issue #24.

@csalgadow We need your feedback for the renderer

Thank you very much
I have downloaded the updated version and now it works very well, it gives message of differences not found except in Text Unified Diff Text Context Diff that does not output any text, although for me it is not necessary.

I will include your scipt in the online voting platform that I have at https://bitbucket.org/csalgadow/demokratian_votaciones/
The idea is that users can check if any of the scripts that collect the vote has been altered so that they can be sure that the vote is secure.

Again, thank you very much for your quick response and for your work with php-diff

You're very welcome.
If you have any other issues/suggestions, please let us know!