Small problem in the PHP highlighter - how to fix?

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by Kasper
Version: 4.0.0271
Avatar
Hi,

Quick steps to reproduce this issue: Open the SDI sample app, change the language to PHP and paste the following lines:

// Hello
        
// This is a test
Now select Tools -> Highlighting style editor. For "Comment Default", change the background to a color that can actually be seen, e.g. blue. You will now see that the empty line between the two comment lines gets the same background color, but this is actually a bug, since // means singleline comments. This seems to work just fine with the C# highlighter, but I can't seem to figure out what makes the difference. What can I change to make this work properly with PHP? :)

Comments (5)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
This is due to all the single comment lines being grouped into one large state in the language definition. If you remove this line from the comment state you can get it how you want:

<RegexPatternGroup TokenKey="CommentLineTerminatorToken" PatternValue="{LineTerminatorMacro}" LookAhead="{LineTerminatorWhitespaceMacro}* // [^/]" IsWhitespace="True" />


Actipro Software Support

Posted 16 years ago by Kasper
Avatar
Okay. Are there no downsides to doing that? As far as I remember, the C# has a line like that as well?
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
It shouldn't affect anything adversely. Alternatively you could change that pattern to look for a single line terminator followed by {WhitespaceMacro}*. That will not let the blank line be a continuation.


Actipro Software Support

Posted 16 years ago by Kasper
Avatar
Could you please provide me with a modified version of the pattern node with that change? I would hate to mess this up my self haha :)
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

<RegexPatternGroup TokenKey="CommentLineTerminatorToken" PatternValue="{LineTerminatorMacro}" LookAhead="{WhitespaceMacro}* // [^/]" IsWhitespace="True" />


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.