Sorry, Graeme, but that won't work. The last line of a paragraph is almost always shorter than it would be if it weren't the last line. So that would prevent wrapping from working in this boundary case. Look at most of the paragraphs in this thread.
Yep, but there was an implied part (in italics) to what I said.
"any line that is shorter than it would be if it were wrapped is considered the start of a new paragraph,
and there is something to wrap to it."
i.e. there are probably no lines in this thread (except I've just created some) that are shorter than they would be if they were wrapped
because there is nothing to wrap to themBut of course, as you say, the boundary case is the problem. Still, slick could do better than it currently does in some cases. For example with
word1
word2
word3
Press delete or paste something at the end of line 1 and slick adds word2 and word3 to the end of line 1 (depending on your settings).
What I would like slick to do is when the cursor
first moves into a comment region, to determine and remember the start and end of the current "wrap region" by inspecting the length of the lines. e.g. if I move the cursor onto word1 above, then line1 is the start and end of the current wrap region. If I start typing more text at the end of line one, slick doesn't wrap word2 to the end of what I'm typing because it was not part of the current wrap region that was determined when I first moved the cursor onto line one.
That would take care of a lot of cases, and many times it would take care of the problem originally posted in this thread. The case that it doesn't take care of is when the line preceding the shorter line (the boundary case that you mentioned) is "full length" because there's no way to tell if the last line should be part of the preceding wrap region or not. Or more generally, suppose I want to have a line that is never wrapped (before or after) e.g.
<a few wrapped lines 1>
Don't wrap this line please.
<a few more wrapped lines 2>
One possibility to take care of this is for slick to notice that the "Don't wrap this line please." line is shorter than it would be if it were wrapped and determine that it's not part of wrap region "lines 1" nor "lines 2". To handle the case of the "Don't wrap this line please" line or the preceding line being full length, the only way to do it is to have a special character sequence somewhere to denote a non-wrapped line or to denote the start or end of a wrapped region e.g. any line ending in # or /nw isn't wrapped (or containing a colon as the OP asked, or matching regex as already said). This would also allow you to have a line longer than the wrap limit if you wanted. As long as everything is configurable, that's the best you can do for this case.
I would put this extra capability under an umbrella of "intelligent comment wrapping" that you could turn on and off on the fly, just as you can turn comment wrap on/off.
Also an option to have the current status of comment wrap shown on the status line would be useful.
As I think someone else mentioned, it would be nice for slick to not do any wrapping in commented code.
Graeme