AdvancedExpressionFolding icon indicating copy to clipboard operation
AdvancedExpressionFolding copied to clipboard

Fold up next-line-open-braces and single block braces

Open JulianRaya opened this issue 9 years ago • 3 comments

This is a feature request. It would be nice to have an option to fold next-line-open-braces up the same line as the keyword and/or hide braces for single line blocks.

so code like this

do
    {
        try
        {
            if ( x > 0 )
            {
                int someVariable = a ? x : y;
                int anotherVariable = a ? x : y;
            }
            else if ( x < 0 )
            {
                int someVariable = ( y + z );
                int anotherVariable = x = x + y;
            }
            else
            {
                for ( int i = 0;i < 5;i++ ) 
                {
                    doSomething( i ); 
                }
            }
            switch ( a )
            {
                case 0:
                    doCase0();
                    break;
                default:
                    doDefault();
            }
        }
        catch ( Exception e )
        {
            processException( e.getMessage(), x + y, z, a );
        }
        finally
        {
            processFinally();
        }
    }
    while ( true );

will look like this

do {
        try {
            if ( x > 0 ) {
                int someVariable = a ? x : y;
                int anotherVariable = a ? x : y;
            } else if ( x < 0 ) {
                int someVariable = ( y + z );
                int anotherVariable = x = x + y;
            } else {
                for ( int i = 0;i < 5;i++ ) doSomething( i );
            }
            switch ( a ) {
                case 0: doCase0(); break;
                default: doDefault();
            }
        }
        catch ( Exception e ) {
            processException( e.getMessage(), x + y, z, a );
        }
        finally {
            processFinally();
        }
    } while ( true );

JulianRaya avatar Jan 27 '17 17:01 JulianRaya

@JulianRaya I have a feeling that this could be better handled by Code Styles.

cheptsov avatar Feb 27 '17 08:02 cheptsov

@cheptsov yea I know code styles would do it, but I was looking for a solution that would not change the style of the code. I have a very different writing style than my coworkers. So I wanted something that would let me view and edit the code in a compact way without changing the style of the code. Changing the style would confuse others who work with it. I can do most of this (example in the original post) now with custom folding regions, it would be nice if this were automated. This plugin is pretty awesome, and it seems like it should have already done a lot of the work towards making a this kind of automation possible.

JulianRaya avatar Mar 15 '17 03:03 JulianRaya

@JulianRaya I actually agree with you.

The Code Style is based on the companies needs. But people have preferred personal styles that sometimes goes against the companies style.

This would allow you to see your preferred code style but you can push changes to Git via the preferred companies code style

ciscorucinski avatar Feb 09 '18 05:02 ciscorucinski