0

Goal - I am trying to change the visual studio solution explorer collapse settings, so that files with extensions such as .razor.css are collapsed under their 'parent' file so to speak.

Expected - My laptop environment does this automatically, I simply name the file (i.e. Index.razor Index.razor.css) and the situation resolves itself without any input from me.

Laptop environment showing collapsible structure.

Actual - My desktop environment does not do this, for some reason it lists all the files consecutively, only collapsing from the folders.

Desktop environment showing no collapsibility.

I have, no doubt, unchecked a box somewhere to get myself into this mess. I would rather not attempt to fix the problem with explicit entries in my .csproj or registry as recommended in this SO question, unless I absolutely must.

If anyone knows a way to control or edit this behaviour in Visual Studio Community 2022 then please do let me know!

Kris
  • 36
  • 1
  • 8

1 Answers1

0

The feature you're looking for is called File Nesting. It is customizable, but in web projects should also have smarter defaults for most of the file types shown.

For non-web projects, you may need to enable it manually. See this GitHub issue for details, but the TL;DR is to add this to your project file:

<ItemGroup>
  <ProjectCapability Include="ConfigurableFileNesting" />
  <ProjectCapability Include="ConfigurableFileNestingFeatureEnabled" />
</ItemGroup>

If you're in a web project or have applied the workaround, I'd first check that the feature hasn't been accidentally disabled. If it's enabled and still not working, consider filing a bug via the VS Feedback tool or via the GitHub repo mentioned above so the feature team can follow up with you directly.

Jimmy
  • 27,142
  • 5
  • 87
  • 100
  • Lifesaver mate, it's been doing my head in for days, turns out I had the toggle turned off at the top of the solution explorer on my desktop. Appreciate the help! – Kris Apr 27 '22 at 01:40