My #pragma region regions keep expanding randomly. How do I prevent this?

Frank Paynter 0 Reputation points
2023-08-04T23:32:34.2133333+00:00

In VS2022 Community edition, I have an Arduino project (using the Visual Micro extension) that has about 20 #pragma region regions. I keep almost all regions collapsed, manually expanding only region of interest.

Unfortunately, every so often one or more (sometimes ALL) the #pragma regions expand on their own, forcing me to once again manually collapse each and every one. I really love the ability to collapse most of my program 'to the background' with #pragma region, but this random expansion is a real PITA.

Does anyone know how to prevent VS2022 from doing this?

TIA,

Frank

Developer technologies | Visual Studio | Other
{count} votes

2 answers

Sort by: Most helpful
  1. Vahid Ghafarpour 23,385 Reputation points Volunteer Moderator
    2023-08-05T03:24:31.0633333+00:00

    Visual Studio has an option called "Track Active Item in Solution Explorer," which, when enabled, automatically expands the active file and regions in the Solution Explorer. This can sometimes lead to the regions expanding unexpectedly.

    0 comments No comments

  2. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2023-08-07T07:32:25.7533333+00:00

    Hi @Frank Paynter

    Welcome to Microsoft Q&A! 

    Could you create a console C++ application and check if it appears? 

    If it only occurs in Arduino project, I suspect it may be caused by the Visual Micro extension. 

    Please try to reset the settings by going to Tools > Import and Export settings > Reset all settings

    Or you can use the keyboard shortcut (Ctrl+M+O) to collapse all regions, not manually collapse each and every one. 

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

     

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.