Bug 507872 - Compare with Active Document giving incorrect result.
Summary: Compare with Active Document giving incorrect result.
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (other bugs)
Version First Reported In: 25.04.1
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-04 23:33 UTC by Richard
Modified: 2025-08-27 18:37 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Screenshot of an example comparison with obvious incorrect result. (122.85 KB, image/png)
2025-08-04 23:33 UTC, Richard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard 2025-08-04 23:33:09 UTC
Created attachment 183791 [details]
Screenshot of an example comparison with obvious incorrect result.

SUMMARY
Comparing 2 files on Windows does not work. Even worse, it does not give an error or indication that something is wrong, it simply states "No differences found" despite there being many differences between the files.

STEPS TO REPRODUCE
1.  Open two files
2.  Select "Compare with Active Document" on the second file when the first file is being viewed.

OBSERVED RESULT
"No differences found"

EXPECTED RESULT
List of differences with color coding.

SOFTWARE/OS VERSIONS
Windows: 25.04.1 from the Microsoft Store.

ADDITIONAL INFORMATION
The bug also exist on the latest nightly 24.11 version as well.
Comment 1 Christoph Cullmann 2025-08-05 16:01:18 UTC
I assume that happens if we find no tool to do the diff, but that should be better reported.
Comment 2 Richard 2025-08-05 16:46:53 UTC
(In reply to Christoph Cullmann from comment #1)
> I assume that happens if we find no tool to do the diff, but that should be
> better reported.

It's true that I do not have any of the kdiff3, kompare, or melt installed or in my PATH. 
But they are all greyed out in Kate and can't be selected. But the built-in compare is not greyed out and should still work?
Comment 3 Christoph Cullmann 2025-08-05 16:53:21 UTC
If I am not wrong we call 'git diff' for that. We have no own diff algo implemented.
Comment 4 Waqar Ahmed 2025-08-05 17:04:10 UTC
Yeah, we use git to get the diff. Can you paste the output of following command:

git diff --no-color --no-index test2334.txt "test2334 - Copy.txt"

And if possible, please share the files in question.
Comment 5 Waqar Ahmed 2025-08-08 04:48:51 UTC
changing status to needsinfo.
Comment 6 Bug Janitor Service 2025-08-23 03:47:16 UTC
๐Ÿ›๐Ÿงน โš ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 7 Richard 2025-08-24 20:12:59 UTC
I think I found the source of the error.

When the file have CR LF as line break, then the compare function works. 
But when the files have only LF (unix) line breaks, then it does not work.

I made new smaller files for testing 
"test_1LF.txt"
> Test
> Test 4
> 123

"test_2LF.txt"
> Test
> Test 2
> 124


Output from "git diff --no-color --no-index test_1LF.txt test_2LF.txt"
> warning: in the working copy of 'test_1LF.txt', LF will be replaced by CRLF the next time Git touches it
> warning: in the working copy of 'test_2LF.txt', LF will be replaced by CRLF the next time Git touches it
> diff --git a/test_1LF.txt b/test_2LF.txt
> index a4ba04d..769dafb 100644
> --- a/test_1LF.txt
> +++ b/test_2LF.txt
> @@ -1,3 +1,3 @@
>  Test
> -Test 4
> -123
> \ No newline at end of file
> +Test 2
> +124
> \ No newline at end of file

The exact same files with CRLR formatting gives the same output, but without the 2 warnings in the beginning. 
Perhaps the warning output somehow prevents Kate from displaying the output properly?
Comment 8 Waqar Ahmed 2025-08-24 20:29:22 UTC
> Perhaps the warning output somehow prevents Kate from displaying the output properly?

That could be true. I will check and fix soon
Comment 9 Waqar Ahmed 2025-08-27 18:34:35 UTC
Git commit dab369b40482f41280c0a5f28fd718a36fe75ce7 by Waqar Ahmed.
Committed on 27/08/2025 at 18:33.
Pushed by waqar into branch 'master'.

diff: fix output being ignored if there is an error/warning

M  +3    -1    apps/lib/diff/diffwidget.cpp

https://invent.kde.org/utilities/kate/-/commit/dab369b40482f41280c0a5f28fd718a36fe75ce7
Comment 10 Waqar Ahmed 2025-08-27 18:37:01 UTC
Git commit 5fabc697b02cc2cf78642b35d8eb441f6340daa2 by Waqar Ahmed.
Committed on 27/08/2025 at 18:36.
Pushed by waqar into branch 'release/25.08'.

diff: fix output being ignored if there is an error/warning


(cherry picked from commit dab369b40482f41280c0a5f28fd718a36fe75ce7)

Co-authored-by: Waqar Ahmed <waqar.17a@gmail.com>

M  +3    -1    apps/lib/diff/diffwidget.cpp

https://invent.kde.org/utilities/kate/-/commit/5fabc697b02cc2cf78642b35d8eb441f6340daa2