mwengler
mwengler

Reputation: 2778

eclipse compare editor stopped showing detailed differences

I've been using eclipse for java android development for 6 months and I love the compare editor. In the last few days I have been hacking away and I think I have all my git ducks in a row, or close enough that things are clean and neat and I can find old working versions of apps.

But it seems in the last day or two, the eclipse compare editor has stopped showing diffs! i right click on uncommitted PlayThread.java and choose to compare with Commit... or HEAD or branch or anything, and no matter how similar the files might be, the compare editor shows one big white bar on its right side, and clicking to go to the next difference highlights the whole file!

I have looked through the git and compare preferences on eclipse and can't find anything that might help.

Any help getting my beautiful compare editor working for me again would be greatly appreciated!

Upvotes: 11

Views: 12797

Answers (4)

andrew pate
andrew pate

Reputation: 4307

With respect to Javascript compare showing nothing, there is a known bug.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=509820

Workaround...

  • Window >> Preferences >> General Tab >> Compare/Patch
  • Deselect checkbox next to "Open structure compare automatically"

Upvotes: 14

VonC
VonC

Reputation: 1329622

Note the latest EGit 5.3.0 (Feb. 2020, 8 years later) improves the right side of the compare editor, using the Eclipse -> Preferences -> Text Editors -> Show whitespace characters mentioned in Vivek's answer.

Text comparisons in Eclipse have been improved to make "Show Whitespace" work in more cases.

Also, concurrent editing of a file in a merge editor and in another editor open on the same file has been improved and works now better and even for files not in the Eclipse workspace.

https://wiki.eclipse.org/images/a/aa/EGit_Compare_Editor_Show_Whitespace.png -- Screenshot of a Java comparison in Eclipse (workspace against index) showing whitespace on the index side

Note that both showing whitespace and concurrent editing depend not only on the way EGit sets up the comparison (which is what we improved) but also on the actual editors being used. These editors are beyond the control of EGit.

With files not in the Eclipse workspace, one may encounter Platform bug 214351 when a file is open in another editor.


Original answer (May 2012):

The compare editor shows one big white bar on its right side,

That means EGit considers the local content of that file (on your disk) differs completely from what have been committed.
The one classic case where that happens is for automatic EOL conversion (Windows <=> Unix), which is why I always set core.autocrlf to false.
See "Git beta on Windows (msysgit) - Unix or DOS line termination".
See also "Distributing git configuration with the code" for managing those EOLs through .gitattribute file (except EGit doesn't support yet .gitattribute file).


In this instance, the OP mwengler reports:

Well that was it.
The way I fixed it was in Eclipse > Window > Preferences > General > Compare/Patch > General on that page I checked "Ignore white space" and now the editor shows my diffs.
But I think I will turn off that autocrlf stuff, I don't think I'm using anything on Windows that can't handle both flavors

See EGit bug 361503 which mentions that this "Ignore White Space" now also honors the core.autocrlf setting.


Eclipse 4.29 (Q3 2023) adds:

Improved "Ignore Whitespace" in Java Compare

Up to now the "Ignore White Space" context menu action in the Java Compare editor ignored all whitespace, including what may be semantically significant whitespace.

Showing all white space changed -- https://eclipse.dev/eclipse/news/4.29/images/show_ws.png

For example, a white space difference in a Java string literal is semantically significant while trailing white space is not.

This has now been inproved so that e.g. white space changes in string literals are also shown while "Ignore White Space" is active.

Hiding insignificant white space -- https://eclipse.dev/eclipse/news/4.29/images/ignore_ws.png

Upvotes: 12

Vivek
Vivek

Reputation: 1125

Today again after long I caught in this issue. Every-time I fix this problem and move on but this time I tried understanding the root cause and get it fixed and since the fix which worked for me is not in the answers to this question, thus adding part with details :

I am using EGit plugin in eclipse, and the problem was same as OP - eclipse compare tool was not highlighting the differences rather a whole block as if the whole file has changed.

Lets understand the issue first , since I was aware that this is related to CRLF vs LF eol , so went to check that first and enabled the visibility as :

Eclipse -> Preferences -> Text Editors -> Show whitespace characters enter image description here

In the above click on configure visibility.

enter image description here

Now as you see highlighted in above image, select the check boxes under Trailing and against both Carrier Return (CR) and Line Feed (LF).

Apply - Save and Close. Now in my case , file looked like this :

enter image description here

and this evident that for me I had CRLF window like eol which further also confirms as I do not have core.autocrlf set to true and by default it is false thus Git actually didn't tried to do anything about my EOL delimiters (as expected in this case).

And until this stage, the compare tool was showing the whole file as changed.

Now, moving to fix which worked for me.

Since, I wanted to get this fix within IDE realm, thus I first converted the particular file to Unix delimiters as : enter image description here

Then my file became with LF (Unix delimiter) eol :

enter image description here

And compare tool started highlighting the delta.

enter image description here

So the issue as it was assumed was because of CRLF (window style) eol and eclipse comparator was not able to highlight delta rather whole file.

Then, instead of changing each file or package to Unix delimiters . I updated in Eclipse->Preferences -> Workspace enter image description here

By this, eclipse takes care of line-endings for new files to Unix, so that text files are saved in a format that is not specific to the Windows OS and most easily shared across heterogeneous developer desktops. After all this compare tool worked happily ever.

Hope this helps.

Upvotes: 2

M R Javeed
M R Javeed

Reputation: 89

Below setting also works for Eclipse Oxygen Release.

It appears that this has something to do with the Structured Compare. To

use the simpler and apparently working version of compare choose:

  • Window > Preferences > General Tab > Compare/Patch
  • Deselect checkbox next to "Open structure compare automatically"

Enjoy text level diffing of ES6 classes.

Regards, Rasool Javeed Mohammad [email protected]

Upvotes: 2

Related Questions