Skip to content

bug(syntax): F77 code highlighting cannot resolve a bare statement with line continuation #1130

Open
@ilayn

Description

@ilayn

Is there an existing issue for this?

  • I have searched the existing issues

Description

If the file https://github.com/scipy/scipy/blob/maintenance/1.14.x/scipy/optimize/lbfgsb_src/lbfgsb.f is opened in VS Code, the syntax highlighting comes quite nice all the way down to the line 967 and then gets confused on a naked format directive and cannot recover until the end of the file. On my system, it looks like the screenshot pasted below.

However, if I transfer a single character from 968 to 967 so format has at least something in the same line, it manages to recover. This leads me to believe that there is a greedy search for an argument after format line but cannot resolve the line continuation context.

Screenshots

image

image

Code Example

!   Code above snippped
      dsave(14) = stp
      dsave(15) = gdold
      dsave(16) = dtd

 1001 format (//,'ITERATION ',i5)
 1002 format
     +  (/,'At iterate',i5,4x,'f= ',1p,d12.5,4x,'|proj g|= ',1p,d12.5)
 1003 format (2(1x,i4),5x,'-',5x,'-',3x,'-',5x,'-',5x,'-',8x,'-',3x,
     +        1p,2(1x,d10.3))
 1004 format ('  ys=',1p,e10.3,'  -gs=',1p,e10.3,' BFGS update SKIPPED')
 1005 format (/,
     +' Singular triangular system detected;',/,
     +'   refresh the lbfgs memory and restart the iteration.')
 1006 format (/,
     +' Nonpositive definiteness in Cholesky factorization in formk;',/,
     +'   refresh the lbfgs memory and restart the iteration.')
 1007 format (/,
     +' Nonpositive definiteness in Cholesky factorization in formt;',/,
     +'   refresh the lbfgs memory and restart the iteration.')
 1008 format (/,
     +' Bad direction in the line search;',/,
     +'   refresh the lbfgs memory and restart the iteration.')

      return
!   Code below snippped

Fortran Version (Free/Fixed Form)

Fixed Form e.g. F77

Version of Modern Fortran

v3.4.2024061901 (pre-release)

Version of Visual Studio Code

v1.92.0

Platform and Architecture

Windows 10

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ilayn

        Issue actions

          bug(syntax): F77 code highlighting cannot resolve a bare statement with line continuation · Issue #1130 · fortran-lang/vscode-fortran-support