• AVR Freaks

Hot!Code Folding

Author
chimera1978
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2010/08/26 21:47:44
  • Location: San Diego, CA
  • Status: offline
2011/04/20 15:21:32 (permalink)
0

Code Folding

This is fairly minor, but an annoyance nonetheless.  It seems that code folding is only partially implemented.  The editor has no problem folding #if ... #endif statements and comments, but doesn't fold if (x) {} statements.  It does not look like it handles #else or #elif, though.  I'm not sure if this is a NetBeans problem or an MPLAB X problem.  I cannot imagine that the users of NetBeans would have let that one go so long, so I'm guessing it is MPLAB X.  While it was not the best at it, MPLAB 8 did a better job at code folding (gVim does an even better job :) ).  Also, there should be options for expanding and closing all folds.  Keyboard shortcuts to do these, as well as expand the current fold, would be great too.

Greg
#1

8 Replies Related Threads

    chimera1978
    Starting Member
    • Total Posts : 63
    • Reward points : 0
    • Joined: 2010/08/26 21:47:44
    • Location: San Diego, CA
    • Status: offline
    Re:Code Folding 2011/12/19 10:32:20 (permalink)
    0
    Bump.
    #2
    mellis
    Super Member
    • Total Posts : 312
    • Reward points : 0
    • Joined: 2009/12/01 13:56:04
    • Location: 0
    • Status: offline
    Re:Code Folding 2011/12/19 14:43:06 (permalink)
    0

    Not sure what you mean about #else or #elif not folding.  This works as expected currently.  So please provide a concrete example. 
    It is true that if (x) {...} or even for (;;) { ... } statement within a code block that is folded do not get additional fold controls.  That is also true for C++ support in Netbeans.

    We will investigate adding additional folds for statements like  if (x) {...}, for (x) {...}, etc which fall within an outer block (function) that is already folded. 

    However, I must ask whether you even bothered to look for the expand and collapse options you mention in the last sentence.

    Please see attached images.

    But the actual menu/mouse clicks are as follows:

    Mouse: Right click in editor on a collapsed function or anywhere inside the scope of an expanded block. Navigate the context menu to find
    the [Code Folds] menu entry (very close to the way it was in MPLAB 8 by the way...). Then choose either Collapse Fold/Expand Fold or 
    Collapse All or Expand All. 

    Keyboard Shortcuts: First open the Options dialog. Then select the Keymap tab. In the search field, you can type "Collapse" and the keymap list will drill down to expose the existing key assignments for the Folding operations that are presented in the editors popup context menu. 


    Regards,




    post edited by mellis - 2011/12/19 14:51:09

    Attachment(s)

    Attachments are not available: Download requirements not met
    #3
    chimera1978
    Starting Member
    • Total Posts : 63
    • Reward points : 0
    • Joined: 2010/08/26 21:47:44
    • Location: San Diego, CA
    • Status: offline
    Re:Code Folding 2011/12/19 15:00:24 (permalink)
    0
    You're right about the #if .. #endif working - I apologize for not updating the comment from the last post back in April.  I was bumping the thread because of if (x) {...} not folding.  I do know how to make the folds that are there to collapse - that is fairly straight forward - I actually wouldn't normally go through the trouble of going to the right mouse menu - I'd just click on the [+] or [-] on the left margin.  As I said, my concern was more {} not folding - that does work in 8.x just fine - I'm not sure why that wouldn't have been considered a requirement for folding.  I see folding comments and pre-processor statements much less of a priority than {}.  And, by the way, it should be any set of {} that can be folded, not just if and for.  I also use {} around code within case statements.

    Greg
    #4
    mellis
    Super Member
    • Total Posts : 312
    • Reward points : 0
    • Joined: 2009/12/01 13:56:04
    • Location: 0
    • Status: offline
    Re:Code Folding 2011/12/19 17:00:38 (permalink)
    0

    No apology required.  Just trying to collect info for a corner case that you may have had and that we had not seen.
    Also, I did not mean to insult you about keyboard shortcuts or menu options for expand all/collapse all.  I responded to your other point from the original thread without considering the age of the post; 
    "Also, there should be options for expanding and closing all folds.  Keyboard shortcuts to do these, as well as expand the current fold, would be great too."


    At any rate, I agree about scopes other than if (x) {...} and for (;;) {...}.  That is what the etc. at the end of my original statement was intended to convey.  So no worries there.   Just so you know, the Code Folding is one of the areas we inherited from Netbeans C++ for which we have not modified ourselves or submitted as a bug report to Oracle/Netbeans in order to meet the needs of our customers more completely.  That is until now ;-).  So it was not so much a case of lack of priority as it is staying focused on the primary task of developing essential embedded support on top of Netbeans for MPLAB X. 


    Thanks for your input and support.  We will get to tuning up this area too.

    Regards,
    #5
    Marttyn
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2013/06/29 23:59:08
    • Location: 0
    • Status: offline
    Re:Code Folding 2019/11/18 04:57:35 (permalink)
    0 (2)
    8 years from the last post here.
    MPLAB X still can not fold {} sad: sad
    #6
    JPortici
    Super Member
    • Total Posts : 852
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re:Code Folding 2019/11/18 05:24:05 (permalink)
    +2 (4)
    go ask the guys at apache.
    MPLABX is just a plugin installed on netbeans, they are in charge of the code editor and stuff
    #7
    oliverb
    Super Member
    • Total Posts : 245
    • Reward points : 0
    • Joined: 2009/02/16 13:12:38
    • Location: 0
    • Status: offline
    Re:Code Folding 2019/11/19 02:05:09 (permalink)
    +2 (2)
    I wonder if there wasn't a deliberate decision to only fold the outermost block. The way folding is implemented in NB means it doesn't work well with deeply nested blocks as the lines indicating the block to fold all appear in the same column in the margin, they don't indent.
     
    On the bright side I just learned about "Surround with Code Folding" which allows you to fold any arbitary block of code by surrounding it with special comments. You just select the block you want to hide, then click the lightbulb and add a description.
    #8
    Marttyn
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2013/06/29 23:59:08
    • Location: 0
    • Status: offline
    Re:Code Folding 2019/11/20 03:59:20 (permalink)
    +1 (1)
    Jack_M
    go ask the guys at apache.
    MPLABX is just a plugin installed on netbeans, they are in charge of the code editor and stuff



    Not helpful... Im not the one in charge of the MPLAB project. Microchip is responsible for their software, even when its based on a different platform. Im just supporting other members that had the same concern i had, and expressing my disappointment. MPLAB is not an open source project.
     
    oliverb
    On the bright side I just learned about "Surround with Code Folding" which allows you to fold any arbitary block of code by surrounding it with special comments. You just select the block you want to hide, then click the lightbulb and add a description.



    Nice to know this. Its not the best approach, but at least can give some flexibility in some cases. Thanks for sharing!
    #9
    Jump to:
    © 2019 APG vNext Commercial Version 4.5