PavelTorgashov / FastColoredTextBox

Fast Colored TextBox for Syntax Highlighting. The text editor component for .NET.
Other
1.21k stars 463 forks source link

Regex in Find not working properly (with newlines) #193

Closed nongcaro closed 4 years ago

nongcaro commented 4 years ago

Hello, I have a string of

Hello
Hello1

And my regex is Hello\nHello1, it's supposed to be highlighted like this:

image

But with FastColoredTextBox, Find gives "Not found", this is an issue when I want to use GetRanges with multiline patterns.

image image

What can I do? Thanks.

nongcaro commented 4 years ago

I have solved my issue with GetRanges using (\r\n?|\n) for newlines, even though after this testing, it's \r\n instead \n. But whatever. This works, but not with Find.

How do I select newlines with Find?

nongcaro commented 4 years ago

Aha, it seems like the Find source code uses GetRangesByLines(), and that doesn't work with multi-lines. If you want to fix this, use a custom Find form with GetRanges() instead of GetRangesByLines().