Menu

#2213 CMake - presence elseif breaks fold/unfold

Bug
closed-fixed
nobody
5
2022-05-22
2020-10-05
No

Report from: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/7901 .

When we put elseif part we will brake fold/unfold for if and also for function until the end of the code.

Ref: https://cmake.org/cmake/help/latest/command/if.html

Code for test:

function(function1)
endfunction()

function(function2 PARAM)

    if(1)
        list(1)
    elseif(1)
        list(1)
    elseif(1)
        list(1)
    else(1)
        list(1)
    endif()

    target_compile_options(${TARGET} PRIVATE ${options})

endfunction()

function(function3 PARAM P2)
endfunction()

Description for above:

  1. When we fold if then all code to the end will be fold (not to endif)
  2. When we fold function2 then all code to the end will be fold (not to corresponding endfunction()).
  3. Note that for default config elseif has fold / unfold but else not.
  4. When we remove only one elseif then fold/unfold for if works better, but still wrong.
  5. When we remove both elseif then all works correct.

I see that lexer cmake has fold.at.else, but this should apply for both elseif and else, and when its off then fold/unfold for if should works correct.
https://sourceforge.net/p/scintilla/code/ci/default/tree/lexers/LexCmake.cxx#l385

Discussion

  • Arkadiusz MIchalski

    Ehh... please change in title ifelse to elseif.

     
  • Neil Hodgson

    Neil Hodgson - 2021-04-24
    • labels: --> lexilla, cmake
    • summary: CMake - presence ifelse breaks fold/unfold --> CMake - presence elseif breaks fold/unfold
    • status: open --> open-accepted
     
  • Neil Hodgson

    Neil Hodgson - 2021-04-24

    This is a bug.

    As I don't use CMake, a fix will have to come from a volunteer.

     
  • Neil Hodgson

    Neil Hodgson - 2021-04-24
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -Report from: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/7901.
    +Report from: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/7901 .
    
     When we put `elseif` part we will brake fold/unfold for `if` and also for `function` until the end of the code.
    
     
  • KeyArts

    KeyArts - 2022-03-08

    Hello,

    this error has been bothering me for a while, so I started to investigate it and posted my solution already for NotePad++

    In Summary: The only thing necessary to avoid this error is that the fold level should not be incremented on an "elseif"-token.

    Please see my changed in the attached file based on https://sourceforge.net/projects/scintilla/files/lexilla/5.1.5/lexilla515.tgz/download

    With regards

     
  • Neil Hodgson

    Neil Hodgson - 2022-04-07

    Lexers have been moved into the separate Lexilla project.
    https://github.com/ScintillaOrg/lexilla

     
  • Neil Hodgson

    Neil Hodgson - 2022-04-22
    • status: open-accepted --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2022-05-22
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB