dparkins / language-fortran

Syntax highlighting for FORTRAN for atom
MIT License
35 stars 16 forks source link

Folding with preprocessor directives #119

Open JureCerar opened 4 years ago

JureCerar commented 4 years ago

Building on the issue #99 ... Fortran does not allow whitespaces before # for preprocessor directives, which makes code folding a bit awkward. So if you have a program for example:

program main
  implicit none
#ifdef MACRO
  print *, " Hello, World!"
#endif
end program main 

and you try to fold main you get:

program main
#ifdef MACRO
  print *, " Hello, World!"
#endif
end program main 

or if you fold everything at level 1 you get

program main
#ifdef MACRO
#endif
end program main 

instead of:

program main
end program main 

This makes code very frustrating to read/write, specially when you have multiple preprocessor directives nested in your code. I think this could be fixed using grammar defined code folding (it works in case of C/C++)?