Menu

#2164 Perl lexer uses different styles for \r and \n on comment line

Bug
closed-fixed
5
2020-04-27
2020-04-01
No

For line comments '#...', when using Windows \r\n line ends, the Perl lexer styles the \r as comment and the \n as default. With Unix \n line ends the \n is in the default style.

This confuses the automatic lexer tests as there is a transition inside the line end. It can also cause visual differences.

Example code in screenshot

There are a couple of possible changes here - show both the line end characters as default or as comments. Since Unix-formatted files have all line ends currently styled as default, styling the \r as default seems the less destabilising. This can be achieved with a simple patch:

            break;
        case SCE_PL_COMMENTLINE:
-           if (sc.atLineEnd) {
+           if (sc.atLineEnd || (sc.ch == '\r')) {
                sc.SetState(SCE_PL_DEFAULT);
            }

Tested with version 4.3.2.

Discussion

  • Zufu Liu

    Zufu Liu - 2020-04-01

    Another simple patch, witch matches behaviors for many other lexers.

                sc.SetState(SCE_PL_DEFAULT);
                break;
            case SCE_PL_COMMENTLINE:
    -           if (sc.atLineEnd) {
    +           if (sc.atLineStart) {
                    sc.SetState(SCE_PL_DEFAULT);
                }
                break;
    
     
  • Neil Hodgson

    Neil Hodgson - 2020-04-05
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2020-04-05

    Changed to changing style to default at line start so that all line end characters of comment lines are in comment line style with [3f7f9e].

     

    Related

    Commit: [3f7f9e]

  • Neil Hodgson

    Neil Hodgson - 2020-04-27
    • status: open-fixed --> closed-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2020-04-27

    Changed to changing style to default at line start so that all line end characters of comment lines are in comment line style with [3f7f9e].

     

    Related

    Commit: [3f7f9e]


Log in to post a comment.