Menu

#700 Fold current block in any line of block

Undefined
fixed
None
Patch
2018-09-29
2018-05-25
Rogerio
No

Currently, to fold the current block (F12) I have to position the cursor in the first row of the block and then press F12 or click the fold button.
This is not practical, since CB already knows which block the line belongs to.
The best would be CB fold the block relative to the line where the cursor is, which is more intuitive

Discussion

  • bluehazzard

    bluehazzard - 2018-06-04

    This patch fixes the behaviour. I honestly don't know the reason behind the check... I think it is legal to always fold the line. Some explanatory comment would be nice...

     
  • Teodor Petrov

    Teodor Petrov - 2018-06-04
    • Type: Feature_Request --> Patch
     
  • Teodor Petrov

    Teodor Petrov - 2018-09-10

    bluehazzard: Have you done some more thorough testing of this patch? For me f12 doesn't work if the files starts with:

    struct str
    {
        char const *c;
        int a[10];
        int *b;
    };
    

    and I try to fold/unfold at line 2 (the open curly brace).

     
  • bluehazzard

    bluehazzard - 2018-09-11

    Ok, i looked again into this, and codeblocks complicates things quite a bit. I do not want to touch all the functions, because i do not know what consequences this has (for example the toggle all folding function is wired...)
    I attach a better patch, but it is still strange.... For example if you have the following code:

    int main()
    {      // (2)
        if()
        {    // (1)
    
        }
        return 0;
    }
    

    If you fold (by pressing F12, what has the meaning toggle) it on point (1) first, and then press F12 again on point (2) it will unfold all. This is not really the expected behaviour, isn't it?

    And this goes on for all folding operations... It is consistent, (by toggling all blocks) but not intuitive.

    My proposed solution is in patch v3: Always toggle only the current Block:
    If you press F12 on point (1) it will fold the inner if. After that if you press F12 on Point (2) it will fold the main function. And in the unfold direction it is the same.

    I am not quite sure about the unfolding code. I Think it is used if you want to unfold text that is folded, not by cursor, but by scripting. I can not test this, because i can not use the derived cbEditor class functions, only the cbEditorBase function in scripting. No idea why this does not work...

     

    Last edit: bluehazzard 2018-09-11
  • Teodor Petrov

    Teodor Petrov - 2018-09-13

    The original code is quite complex and odd. I think either scintilla had awkward api back when this was first written or someone didn't understood how the api works. I'll prepare a simpler patch, soon... And then we'll fix the features I've accidentally removed. :)

     
  • Teodor Petrov

    Teodor Petrov - 2018-09-14

    This is also funny:

    #define SC_FOLDACTION_CONTRACT 0
    #define SC_FOLDACTION_EXPAND 1
    #define SC_FOLDACTION_TOGGLE 2
    
    0 = Unfold; 1 = Fold; 2 = Toggle folding.
    
     
  • bluehazzard

    bluehazzard - 2018-09-15

    I was thinking this code is intentional as complicated as it is. Because for example if you toggle all folding in scintilla it only looks at the first possible folding line and then folds the rest of the document like the first line. The code in codeblocks makes a real toggle, line for line... If this is good or bad, i don't know. It is complicated...

     
  • Teodor Petrov

    Teodor Petrov - 2018-09-15

    What do you mean by toggle all in scintilla? I've almost finished cleaning up this code. I'll post a patch for testing soon.

     
  • Teodor Petrov

    Teodor Petrov - 2018-09-16

    Topic where you could post feedback is here: http://forums.codeblocks.org/index.php/topic,22821.0.html

     
  • Teodor Petrov

    Teodor Petrov - 2018-09-29
    • status: open --> fixed
    • assigned_to: Teodor Petrov
     
  • Teodor Petrov

    Teodor Petrov - 2018-09-29

    In trunk, thanks for reporting, let us know if you find more problems.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.