Skip to content

Conversation

@pmularien
Copy link
Contributor

I observed that on Windows systems, the highlighting is off on the code grid view due to an issue with the incorrect .split method being invoked on the source file (String). This results in a "double spacing" effect in addition to the incorrect highlighting.

The actual .split method being invoked is StringLike.split, which translates into a regex [\r\n] which is then passed to the Java String.split method. The behavior of this method will cause 2 lines in the resultant array.

Issue is resolved if treating as a single String (and not a Char array), which will invoke the Java String.split(String regex) method, and correctly treat the "\r\n" as a single expression. This should work correctly on other platforms with a single character line ending (Unix and Mac).

After looking at the history of this file, it seems you may have had a similar issue in the past... without knowing the history, I will let you determine the best fix :) but I have verified that this does correct the behavior I was seeing with a local snapshot build of the plugin.

FWIW I encountered this issue with Scala 2.11.4, I haven't tested the fix with 2.10. Please have a look and let me know what else needs to be done to make this a good pull?

to the .split method being translated by StringLike.split into
a regex [\r\n] which will cause 2 lines in the resultant array.
Issue is resolved if treating as a single String, which will
invoke the Java String.split(String regex) method, and correctly
treat the "\r\n" as a single expression. This should work correctly
on other platforms with a single character line ending (Unix and Mac).
@Kwestor
Copy link
Contributor

Kwestor commented Jan 7, 2015

I have tested it on my windows7 machine and it fixes the problem for me, thanks @pmularien! I had this issue next on my task list.

My only nitpick is can you create some small unit-test to check if everything works for both \r\n and \n to avoid problems with Windows in future?

@pmularien
Copy link
Contributor Author

@Kwestor good idea, I had thought about that, one of the difficulties with this (without resorting to hacking system properties) is the code's use of System.getProperty to get the line separator. Let me poke around and see if there's a good way to get around this.

sksamuel added a commit that referenced this pull request Jan 7, 2015
Correct issue with line double spacing / highlighting in Code Grid view on Windows
@sksamuel sksamuel merged commit ffd8c05 into scoverage:master Jan 7, 2015
@sksamuel
Copy link
Member

sksamuel commented Jan 7, 2015

Thanks for PR!

@pmularien pmularien deleted the fix-linespace-windows-issue branch January 8, 2015 14:26
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

Successfully merging this pull request may close these issues.

3 participants