Soft-wrapped lines are marked up poorly


#1

I was writing a package to add highlighting of trailing white space (yes, I know there is an auto-remove trailing whitespace package — sometimes I want to see it and have the option), but I ran into a hurdle. First, the good news: Atom marks up trailing whitespace with a special class (<span class="trailing-whitespace" />). The plugin was essentially two lines of CSS (!!!).

But there is a problem with soft-wrapped lines. The thing is, Atom hard-wraps them. They aren’t soft-wrapped — it realizes they need to wrap, so it creates a new line. These lines aren’t marked up in any way that indicates that they are part of a longer, soft-wrapped line. So pretend that this is a really long line:

This is a really long line.

And say it soft-wraps like this:

This is a_
really long line.

See the _ after This is a? That’s representing marked-up trailing whitespace. Boo. There is no way to tell the difference between that line soft-wrapped, and the resulting two lines if they were originally written that way.

Ideas:

  1. Don’t mark trailing whitespace as trailing whitespace when it is on a non-last portion of a soft-wrapped line.
  2. Wrap soft-wrapped lines in some sort of “soft-wrapped-line-group” element.
  3. Both?

#2

Screen shot for extra clarity:

The white on red is my style for “trailing whitespace”. But this isn’t trailing whitespace, it is in the middle of an actual line.


#3

Idea 2 will also allow people to write styles indenting soft wrapped lines, which is nice.


#4

I believe in fact that long lines should not be splited in several line elements, but instead just the line lengh style to “max-width:80ch”, so they will be in fact of 80 characters in width.