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

Issue: Code breaking when there is no change in a line #141

Open
ravellaabhinav opened this issue Apr 25, 2023 · 5 comments
Open

Issue: Code breaking when there is no change in a line #141

ravellaabhinav opened this issue Apr 25, 2023 · 5 comments

Comments

@ravellaabhinav
Copy link

ravellaabhinav commented Apr 25, 2023

Suppose if there are 5lines of code to check difference and there are changes in Line:1,2,5. The library is helping to print the difference with line number for line:1,2 and when there is a break in line number i.e.,line5 here line number is not getting printed instead char count number is being printed

Error:


image

@dmsnell
Copy link

dmsnell commented Apr 25, 2023

@ravellaabhinav I'm having trouble undestanding what the issue is. From your screenshot, it looks like the library is providing the right indications of what changed in the text.

What is your specific question? What specifically are you seeing as broken? What specific output would you have expected differently?

@ravellaabhinav
Copy link
Author

ravellaabhinav commented Apr 25, 2023

@dmsnell, can you see in screenshot that it is showing 85 as line number in the difference, but there are only 7lines in the input

@dmsnell
Copy link

dmsnell commented Apr 25, 2023

aha, thanks @ravellaabhinav - that's clear now, and I missed that.

what tool are you using there? the library itself doesn't really report line numbers, so that's why I was confused.

@ravellaabhinav
Copy link
Author

ravellaabhinav commented Apr 25, 2023

@dmsnell: That's my UI and nothing much.


I used the same logic:

function diff_lineMode(text1, text2) { var dmp = new diff_match_patch(); var a = dmp.diff_linesToChars_(text1, text2); var lineText1 = a.chars1; var lineText2 = a.chars2; var lineArray = a.lineArray; var diffs = dmp.diff_main(lineText1, lineText2, false); dmp.diff_charsToLines_(diffs, lineArray); return diffs; }

@dmsnell
Copy link

dmsnell commented Apr 25, 2023

@ravellaabhinav this is a bit beyond me, and I'm guessing if you could share the code powering that UI it might help.

do you think it's possible there's a mismatch between what diff-match-patch is reporting and what is being interpreted as line counts?

what is the output of the call to diff-match-patch in the example behind the screenshot? can you paste the output directly here?

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

2 participants