GarfieldKlon
GarfieldKlon

Reputation: 12180

Enable show differences in line separators in a diff with Intellij IDEA 13

I'm using IDEA 13.0.1. A unit test is failing because of some line separator stuff. But when I try to compare the two results, IDEA says "Contents have differences only in line separators".

And I can't find a setting where I can say show me these differences. Is there one?

Upvotes: 8

Views: 12607

Answers (3)

Petar Petrov
Petar Petrov

Reputation: 43

The key is in what @user1633977 said.

To solve this problem, always use System.lineSeparator() to create your separators. That way they will always be the same and will be OS-independant.

(Remember that different OS can use different symbols as line separators).

Upvotes: 0

Charles
Charles

Reputation: 620

I ran into the same problem recently. I found a workaround for it, is not that pretty but did the job:

yourString.replaceAll("\n", "").replaceAll("\r", "");

Upvotes: 5

user1633977
user1633977

Reputation: 111

I ran into the same issue, I couldn't find a way to show the difference by clicking show differences, but if you put a break point and look at the strings, they have the line separator written out. For me one string had \n and one had \r\n. \r is also a possible line separator.

Upvotes: 5

Related Questions