Logically nothing should be painted except for 'foo' (having sLineBreak glued next to it, sLineBreak excluded ).
YourMarkup.SearchString := ('foo' + chr(13) + chr(10));
Then don't include the line break in the search.
I remember from one of your previous posts, that multiline-regex don't work (that is a bug / but currently low priority). Have you tried single line regex?
^foo|foo$
If not, you should be able to subclass the markup and do your own search.
At least yellow and gray should be painted at same spots as underline. A bug ?
Even though the linebreak is not a visible char, and SynEdit does not (yet) have an option to "show" them (like it has for spaces), the linebreak exists. => E.g. it can be copy and pasted.
And it can be highlighted.
You get the same if you change the "selection markup" to have underlines.
It's a mixture of 2 features:
1) char/font based marks (bold/underline/italic) => they are applied to all chars, including none-printed (space/line-break).
Though only underline is visible, unless spaces are printed as dot.
2) Color based (including frame) => They also apply to the area past the end-of-line.
This is to avoid a so called "ragged" selection (I.e. if you select multiply lines, the empty space on the right after eol is shown in selection color).
I wouldn't change that as default.
Though individual highlights/markups may be able to decide for themself, if this should happen.
Again not tested, but...
1) As I said, if the line-break is excluded it should not happen at all.
2) If the line-break is included, then you may need to override
function GetMarkupAttributeAtRowCol(const aRow: Integer;
procedure GetNextMarkupColAfterRowCol(const aRow: Integer;
And have them stop the color, after the line-break.
I am not adverse to a build in option. But that will be quite some work. It won't be just a boolean flag. It needs to consider other factors too (like line-wrapping). And it needs very careful consideration where the code goes. So it doesn't need to be replicated in tons of places.
---
Note, there a quite a few todo around line breaks.... Like an option to keep/preserve cr/lf as found in the file.