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

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

Closed
csalgadow opened this issue Jul 16, 2020 · 8 comments · Fixed by #51
Assignees

Comments

@csalgadow
Copy link

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

@DigiLive
Copy link
Collaborator

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?

@JBlond
Copy link
Owner

JBlond commented Jul 16, 2020

@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.

@JBlond
Copy link
Owner

JBlond commented Jul 16, 2020

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')) {

@DigiLive
Copy link
Collaborator

DigiLive commented Jul 16, 2020

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.

@DigiLive DigiLive self-assigned this Jul 16, 2020
@DigiLive DigiLive added this to the Main- SubRendering milestone Jul 16, 2020
@DigiLive DigiLive changed the title Know if there are no differences First or last x lines of text are shown even when there's no difference between the two compared texts. Jul 16, 2020
@DigiLive
Copy link
Collaborator

Related to issue #24.

DigiLive pushed a commit that referenced this issue Jul 17, 2020
First or last x lines of text are shown even when there's no difference
between the two compared texts.
@DigiLive DigiLive mentioned this issue Jul 17, 2020
JBlond added a commit that referenced this issue Jul 17, 2020
@JBlond
Copy link
Owner

JBlond commented Jul 17, 2020

@csalgadow We need your feedback for the renderer

@JBlond JBlond reopened this Jul 17, 2020
@csalgadow
Copy link
Author

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

@DigiLive
Copy link
Collaborator

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

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

Successfully merging a pull request may close this issue.

3 participants