#1849 HTML/PHP highlighting resuming breaks in some cases

Bug
closed-fixed
5
2016-09-05
2016-08-03
No

When the HTML/PHP/XML lexer resumes on styles SCE_H_QUESTION, SCE_H_XMLSTART, SCE_H_XMLEND or SCE_H_ASP, it breaks.

This is specifically visible with this example (from https://github.com/geany/geany/issues/1143):

<p>Paragraph 1</p>

<?php function("1
2", 'sql') ?>

<p>Paragraph 2</p>

Doing anything that leads for styling to resume at the start of line 3 (<?php...) will break highlighting of the part after ?>. adding a line break in either of the PHP strings is such a thing.

This is because when resuming inside a string, the lexer moves back to the start of the previous line not starting in a string. This is position 0 on line 3, which has style SCE_H_QUESTION. This leads to start with this style, but unfortunately no code is ever handing going out of this style, that is supposed to only be set once and never reached. Hence, when the code resumes the non-script style, it resules in state SCE_H_QUESTION, and never leaves it.

Attached patch alters the initial style when it is one of those for which getting out is never handled and restes it to default style. The resumed lexing will be all fine, because it'll re-lex it, and because those styles never span multiple lines and the lexer always resume at a line start.

Discussion

  • Neil Hodgson

    Neil Hodgson - 2016-08-14
    • status: open --> open-fixed
    • assigned_to: Neil Hodgson
     
  • Neil Hodgson

    Neil Hodgson - 2016-08-14

    OK, that looks good. Committed as [943af3].

     

    Related

    Commit: [943af3]

  • Neil Hodgson

    Neil Hodgson - 2016-09-05
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks