abusalimov / SublimeCImproved

(NO LONGER MAINTAINED) Improved syntax for C/C++/Objective-C, with a special support for sources of Linux kernel, CPython, etc.
https://packagecontrol.io/packages/C%20Improved
MIT License
51 stars 45 forks source link

Code folding with macro #1

Closed leesei closed 10 years ago

leesei commented 10 years ago

I can fold the whole function but the #if is not foldable.

int case1() {
    /* statements */
    int err = 0;

    #if MACRO
    /* statements */
    #endif

    /* statements */
    return err;
}

#if is foldable but the function folding breaks.

int case2() {
    /* statements */
    int err = 0;

#if MACRO
    /* statements */
#endif

    /* statements */
    return err;
}

Thanks.

abusalimov commented 10 years ago

Thank you for reporting this. I am currently on a journey, so I'll unvestigate it after returning home in March.

leesei commented 10 years ago

Thanks On 20 Feb 2014 19:36, "Eldar Abusalimov" notifications@github.com wrote:

Thank you for reporting this. I am currently on a journey, so I'll unvestigate it after returning home in March.

— Reply to this email directly or view it on GitHubhttps://github.com/abusalimov/SublimeCImproved/issues/1#issuecomment-35611546 .

abusalimov commented 10 years ago

That's weird. The same bug is observed when using any other syntax.

(
    x
            {
        {
        }
            }
    y
)

Folding works for the outermost parens, for x/y pair, but not for braces with broken indentation.

It seems that Sublime ignores foldingStartMarker/foldingStopMarker from tmLanguage at all and uses indentation instead to determine regions to fold (View.indented_region API call).

There is nothing I can help you with, sorry. The only possible way I see now is to override fold command manually (Packages/Default/fold.py) so that it will use custom rules to find out which regions to fold.

leesei commented 10 years ago

I see. Thanks for your study. I think I'll report this bug to Sublime Text then.

abusalimov commented 10 years ago

That's ok, you're welcome. Thank you too!