Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-23777

QML syntax highlighting fails [differently] when a line ends with a string delimiter

    XMLWordPrintable

Details

    • macOS, Windows
    • 626807c94e3c1e3d947de2359f26e15dd82641f7 (qt-creator/qt-creator/4.12) ba580bba83a261e6327334b947c01fa172b30362

    Description

      When a line ends in a string delimiter (" or ') followed by a newline, syntax coloring fails.  On subsequent lines following the string constant, the highlight colors are applied to the next line.

      For example, here the shader code is on the next line for readability.

      fragmentShader: "
         varying highp vec2 qt_TexCoord0;
         uniform sampler2D source;
         ...

      If the newline follows immediately after the ",  syntax highlighting is off by one on all the following lines.  The highlighting is off by an additional line for each instance of a delimiter following by a newline.

      As a workaround, place a space after the string delimiter and highlighting works as expected.

      Update: unfortunately, every time you save a file in Creator, it trims trailing white space from the file, which in turn causes this issue to return.

       

      -----------------------------------

      Reopen Update: 

      With 4.12.2, the previous case described is fixed, but there is a new, similar issue.

      Now, if a line ends with a string delimiter immediately followed a newline, it works as intended. But if a line has a delimiter followed by anything on that line, then highlighting is once again off by one line, though now the highlights for the line are taken from the next line.

      The following multiline string causes QML highlighting to fail.

      property string aString: "asdf
                                string" 

      But if the first delimiter is followed immediately by the new line, it works as expected:

      property string aString: "
                                asdf
                                string" 

      And if the first line of the string has the newline escaped, it works as expected. Only the first line has an effect:

      property string aString: "asdf \
                                string "

      And if you put one or more escaped delimiters in the string, on the first line, highlighting works again

      property string aString: "as\"df 
                                string"

      As before, the highlighting is off by an additional line for each problematic multiline string.

       

      Attachments

        1. syntaxHighlightingErr2.png
          5 kB
          Terence Conklin
        2. syntaxHighlightingIssue.png
          12 kB
          Terence Conklin

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              cstenger Christian Stenger
              tec Terence Conklin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes