microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

Trying to stop auto-expand when there is a syntax error #9284

Closed miles-1 closed 2 years ago

miles-1 commented 2 years ago

Issue Type: Bug

When I type a syntax error midway through a document, all previously-collapsed functions/methods from that point forward auto-expand. When there are potentially 20+ functions in a document, and I want the currently-unimportant ones collapsed, I hate having to go and re-collapse every method when there is a syntax error, even just for a split second (e.g., when I type an open parenthesis and have not yet typed the close parenthesis).

When I used code --disable-extensions, this issue did not occur. However, none of the steps during the extension bisect caused the issue to reappear either, and multiple attempts of the extension bisect conclude different results, so I am not sure if the results reported here are accurate, but by golly I'd really like to figure this out.

Steps to reproduce (python example):

  1. Make a new python document.
  2. Type out three or four function definitions. For simplicity, you can put "pass" as the only line in each function definition.
  3. Mouse over to the line numbers and click the carrot to minimize/collapse each of the function definitions.
  4. Re-expand one of them (any is fine as long as it isn't the last function).
  5. For that function, make some kind of syntax error in the body of the function, e.g., type a single parenthesis.

On my end, when extensions are not disabled, this causes all the function definitions from this point forward to expand, and they can only be collapsed by hand again after that.

Extension version: 1.9.8 VS Code version: Code 1.66.2 (dfd34e8260c270da74b5c2d86d61aee4b6d56977, 2022-04-11T07:46:01.075Z) OS version: Windows_NT x64 10.0.19044 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i5-11400 @ 2.60GHz (12 x 2592)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|11.73GB (6.34GB free)| |Process Argv|--crash-reporter-id 32d6ede4-adef-4e29-8898-09d0283014ef| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyl392:30443607 pythontb:30283811 pythonvspyt551:30345470 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 pythondataviewer:30285071 vscod805cf:30301675 pythonvspyt200:30340761 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 vsc1dst:30438360 pythonvs932:30410667 wslgetstarted:30449410 pythonvsnew555:30457759 vscscmwlcmt:30465135 cppdebugcf:30475217 vscaat:30438848 ```
michelleangela commented 2 years ago

@miles-1 This repository is for the C/C++ extension. Did you mean to report this issue for the Python extension at https://github.com/microsoft/vscode-python/issues?

miles-1 commented 2 years ago

Thanks for your reply @michelleangela, according to an extension bisect I ran in my VSCode, it was this extension that was causing the problem, but like I mentioned before, I was getting different results for different attempts of an extension bisect. Apologies for bothering you with this, but would you just recommend I put this in the main VSCode issue section?

michelleangela commented 2 years ago

If the issue reproduces even with all extensions disabled, then the issue could be VS Code client and should be reported at the VS Code repository. I would try with a Typescript code with all extensions disabled.

If it is caused by one of the extensions, I would try to enable one extension at a time to see which extension is causing the issue. I'm not familiar with the bisect tool VS Code uses and if the tool already does this. Once the extension is determined, I would report the issue at the repository of that extension.

miles-1 commented 2 years ago

I do believe that's what the extension bisect tool is doing (disable half of the extensions at a time until the problem-creating one is identified), but it seems unlikely that the C/C++ extension would be causing this issue. I'll keep poking around. Thank you!

michelleangela commented 2 years ago

I tried the following C++ code sample to check code folding feature on the C/C++ extension, and I couldn't reproduce the issue when typing a syntax error in function test3().

If it turns out to be the C/C++ extension on your end, could you provide a screen clip of the issue?

void test()
{
    int a = 0;
}

void test2()
{
    int a = 0;
}

void test3()
{
    (
}

void test4()
{
    int a = 0;
}
miles-1 commented 2 years ago

I also just tested this and was not able to reproduce this in C++, so perhaps this is more python-specific. I'll do some more investigation. Thanks again!