user14766639
user14766639

Reputation:

Visual Studio code folding not working properly

does someone already has experienced this "issue" on visual studio? it did not fold the code on the brackets, just on the function header, should have a - on line 32,35 like on the line 25

enter image description here

Upvotes: 17

Views: 21423

Answers (8)

Peter
Peter

Reputation: 2270

Had something similiar.
At work it turned out theme dracula had a bug hiding the fold line dark ..

Upvotes: 0

Shani Kehati
Shani Kehati

Reputation: 550

I found my setting for "Editor: Folding" was false! i.e disabled. (I don't recall why)

Make sure it's on, i.e enabled.

enter image description here

Upvotes: 0

Jossy
Jossy

Reputation: 1011

I tried all of the solutions posted so far to no avail. I ended up copying and pasting the code to a new file and the folding worked perfectly.

Upvotes: 1

Zachwuzhere
Zachwuzhere

Reputation: 489

If you stop the outlining and then start it back up, it should refresh/reset the outlining data for that file.

first goto Edit->Outlining->StopOutlining
then goto  Edit->Outlining->StartAutomaticOutlining

This fixed my issue with code folding wrong code sections, and just doing weird stuff.

I made an extention for Visual Studios 2022 to do it in one click, because I was bored. https://marketplace.visualstudio.com/items?itemName=zachwuzhere.ext123

Upvotes: 0

BilgeKhagan
BilgeKhagan

Reputation: 61

There is a setting in the VS.Code : "Settings / Editor: Folding Strategy" I set this to "indentation" while other option is only "auto".

I guess there sometimes problems with other extensions.

Upvotes: 6

xaedes
xaedes

Reputation: 1706

I had the same problem with python code. For me this helped:

File -> Preferences -> Settings -> Text Editor -> Folding Strategy -> Set to "indentation"

"Folding Strategy - Controls the strategy for computing folding ranges"

This was set to "auto" for me, after changing to "indentation" it works.

I suspect the "auto" setting uses something smarter which may break depending on system, environment and used imports.

Upvotes: 56

user14766639
user14766639

Reputation:

Solved: Visual Studio -> Tools -> Options -> Text Editor -> C\C++- > View and set Outline Statement Blocks to true

I dont know how, but i had this option as false.

Upvotes: 0

Ladrillo
Ladrillo

Reputation: 89

Well that's strange.

You can try a couple things:

  • Re-opening the IDE.
  • Try that piece of code somewhere else (to discard a more general issue).

Does it happen anywhere else? If it does, it could be an editor option.

Regards.

Upvotes: 1

Related Questions