#962 improvement of folding for Fortran

Committed
closed
Neil Hodgson
4
2014-08-24
2012-11-24
darmar
No

I am about current folding for Fortran.
For example, for the code
if (a > b) then
print *, 'Hi'
else
print *, 'Hello'
endif'

the current implementation of the folding makes so, that after folding 'if' statement, the code until 'endif' is hidden, like
if (a > b) then
----------------------

I think, it is not the best solution, because it hides the logic. I would expect, that the code between 'if' and 'else' would be hidden only, like:
if (a > b) then
-------------------------
else
print *, 'Hello'
endif'

For example, such type of folding is for Python (in C++ it depends on how '{ }' are used)
(I have attached a screen-shot to understand better what I mean.)

If you would agree, I could try to implement required changes in Fortran folding.

Discussion

1 2 > >> (Page 1 of 2)
  • darmar
    darmar
    2012-11-24

    screenshot

     
    Attachments
  • Neil Hodgson
    Neil Hodgson
    2012-12-30

    See the implementation of fold.at.else in the C++ lexer for an example of this. A good implementation of this for Fortran may be included. I won't be working on it myself.

     
  • Neil Hodgson
    Neil Hodgson
    2012-12-30

    • assigned_to: nobody --> nyamatongwe
    • priority: 5 --> 4
    • milestone: --> Won't_Implement
     
  • darmar
    darmar
    2013-10-01

    Hello Neil,

    I have implemented required changes in LexFortran.cxx file to improve folding in Fortran. The changes are tested on my custom CodeBlocks IDE build (darmar.vgtu.lt) and I haven't received any complains about it from users. So, I hope, there are no bugs left.

    Besides, the attached patch fixes bug related to folding, when WHERE statement in fixed-form source file is used.

     
    Attachments
    • Neil Hodgson
      Neil Hodgson
      2013-11-03

      Indentation should match existing code by using tabs instead of spaces.

      The test here is pointless:
      if (isPrevLine)
      isPrevLine = false;

       
  • darmar
    darmar
    2013-11-04

    Thank you, Neil, for your response.

    I think, that the problem with 'tabs' is that the current highlighting for Fortran77 doesn't support 'tab-based' source code. As a result, the folding is wrong (same as highlighting). 'Tab-based' source code highlighting was never implemented in Scientilla. If I am wrong, maybe you have an example with source code, which causes the problem you mentioned?

    About:
    if (isPrevLine)
    isPrevLine = false;

    Sorry, but I don't understand, why you think it is pointless?

     
    • Neil Hodgson
      Neil Hodgson
      2013-11-04

      The spaces are in your C++ code "fortran_lexer.patch".

      The code

      if (isPrevLine)
      isPrevLine = false;
      

      has identical effects to

      isPrevLine = false;
      
       
  • darmar
    darmar
    2013-11-05

    I have modified the patch (file is attached).

    If you have more comments, I am ready to make changes again.

     
    Attachments
    • Neil Hodgson
      Neil Hodgson
      2013-11-06

      That patch is still using lines with indentation containing spaces.

       
  • darmar
    darmar
    2013-11-06

    Sorry, I forgot to change the spaces to the tabs.

    Now, should be OK.

     
    Attachments
1 2 > >> (Page 1 of 2)