vscode-fortran-support icon indicating copy to clipboard operation
vscode-fortran-support copied to clipboard

bug(syntax): Comment in line continuation with apostrophe breaks highlighting

Open albertziegenhagel opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

In fixed-form Fortran, if I have a function call that spreads over multiple lines and somewhere in the middle of those lines there is a comment line (starting with a c in the first column) that includes an apostrophe (') the syntax highlighting is completely messed up after the apostrophe.

It seems that the comment line is not recognized correctly and then the apostrophe starts a string literal that is never matched. If I use an exclamation mark (!) instead of the c to start the comment line, the comment seems to get recognized correctly.

Screenshots

Incorrect: image

Expected: image

Code Example

      call foo(a,
     & b,
c I don't like this comment
     & d)

Minimal, compiling program:

      program hello
        print*, sign(1,
c I don't like this comment
     &  -5)
      end program hello

Fortran Version (Free/Fixed Form)

Fixed Form e.g. F77

Version of Modern Fortran

v3.4.2023053001

Version of Visual Studio Code

1.79.2

Platform and Architecture

Windows

Additional Information

No response

Edit: added a minimal example that is a valid, compiling program (tested with gfortran and ifort)

albertziegenhagel avatar Jun 20 '23 14:06 albertziegenhagel

I will have to have a more detailed look in the grammar syntax files to make sure, but I suspect that there line continuation condition for fixed form is either wrong. I will add this to the backlog

gnikit avatar Jun 22 '23 13:06 gnikit

@albertziegenhagel is this issue still open ?

Divyansh200102 avatar Mar 03 '24 12:03 Divyansh200102

Yes, I can confirm that this is still an issue (checked version v3.4.2024041503).

albertziegenhagel avatar Apr 16 '24 19:04 albertziegenhagel