microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.96k stars 29.18k forks source link

folding messed up #231717

Open raphael12333 opened 1 week ago

raphael12333 commented 1 week ago

Hi i use a cpp project

When using Sublime Text for a short time, the issue is gone after returning to VS Code but it comes back later, probably when using "Convert Indentation to Spaces"

Here is how it looks: Image

all my VS Code settings are default regards

raphael12333 commented 1 week ago

here is another example Image

raphael12333 commented 1 week ago

i code like this:

if (x)
{
    do();
    do();
}
if(x)
    do();

and i use some #if 0 maybe these are causes

aeschli commented 1 week ago

Please provide the code example to reproduce. Also describe what exactly is messed up. Do you use an extension for C++?

raphael12333 commented 1 week ago

I do not manage to make a reproducible example The above screenshots show that the functions are not folded properly, do you see what i mean? I don't use C++ extension

i think it gets triggered when i do "Convert Indentation to Spaces", then fold all the only way i found to make it stop is to use sublime text for few hours and then come back

Do VS Code uses some config/cache file for the folding?

raphael12333 commented 1 week ago

Getting the issue right now: Image

There shouldn't be 2 arrows isn't it?

Here is the result when I press the second one: Image

This is what i mean by messed up It seems to me there is a bug that makes VS Code to propose to fold parts it shouldn't

So when I "fold all" sometimes (using ctrl+k+0), it folds stuff it shouldn't and then some parts of the file looks like the first screenshots i sent

below is the file i'm getting the issue with right now kc.zip

i don't remember having used "Convert Indentation to Spaces" before getting the issue now

raphael12333 commented 1 week ago

by ctrl+k+0, i mean i press this for 0 Image

with no shift/caps, so i guess i should say ctrl+k+à...

aeschli commented 1 week ago

If you don't use an extension, then you get folding based on indentation: A folding region starts when a line has a smaller indent than one or more following lines and ends when there is a line with the same or smaller indent.

You are right, there shouldn't be a folding marker on line 138, but on line 139

What could be an explanation is that when you do 'Convert Indentation to Spaces' and have regions folded, then we try to keep persisting the folded ranges.

You can remove these persisted ranges by selecting all and run the command Remove Manual Folding Ranges

I can't reproduce the issue. It would be interesting to get the content where line 137 has a folding range, just before you run Remove Manual Folding Ranges When you see this again, can you undo the Remove Manual Folding Ranges and get that content?

raphael12333 commented 4 days ago

Hello I just got the issue after running Convert Indentation to Spaces Selecting all and running Remove Manual Folding Ranges fixed it instantly, thank you very much

I kinda struggled to understand when you talked about the content to send but i hope the below will provide an equivalent for the requested information

I did ctrl+z to bring back the issue, it starts with this: Image

result after running the command: Image

here is the content of custom_GScr_LoadGameTypeScript:

void custom_GScr_LoadGameTypeScript()
{
    hook_GScr_LoadGameTypeScript->unhook();
    void (*GScr_LoadGameTypeScript)();
    *(int*)&GScr_LoadGameTypeScript = hook_GScr_LoadGameTypeScript->from;
    GScr_LoadGameTypeScript();
    hook_GScr_LoadGameTypeScript->hook();

    unsigned int i;

    if(*fs_callbacks_additional->string && !Scr_LoadScript(fs_callbacks_additional->string))
        Com_DPrintf("custom_GScr_LoadGameTypeScript: Scr_LoadScript for fs_callbacks_additional failed.\n");

    for (i = 0; i < sizeof(callbacks) / sizeof(callbacks[0]); i++)
    {
        if(callbacks[i].custom)
            *callbacks[i].pos = Scr_GetFunctionHandle(fs_callbacks_additional->string, callbacks[i].name);
        else
            *callbacks[i].pos = Scr_GetFunctionHandle(fs_callbacks->string, callbacks[i].name);

        /*if (*callbacks[i].pos && g_debugCallbacks->integer)
            Com_Printf("%s found @ %p\n", callbacks[i].name, scrVarPub.programBuffer + *callbacks[i].pos);*/ //TODO: verify scrVarPub_t
    }
}

Could the /**/ participate in triggering the issue? I talked about it with someone recently and he said: Image

Please let me know if there are other things i could do to help to figure out the cause

Regards