If I understand what you need, you ask how to stop the code below the line that I am editing from automatically expanding. , I would like to say that there is no solution either from official sources or because of anything. The codec collapses with the idea of ββideal code editors such as Visual Studio.
Let me explain to you why this is happening and how to prevent it. First, let me explain the basic conditions for collapsing code to work. Code code editors use Lexers and Parsers to support the language, parsers use regular expressions for the syntax of the corresponding language, entered by the Coder or someone else, in this sequence code editor stores all locations where characters such as ; , { and } , " .
For the collapse of the code to work effectively, there must be an equal number of characters specified in the exact order in the editable code, whenever there is something in the source code that does not correspond to the syntax of the language, the parser flags inform about the editing and formatting of this error.
Returning to your problem, let's talk about what you are faced with, in order to better understand it, consider a simple block of code;

and consider that there are a few more functions below AddNumbers that are also reset. Now, if I understand you, then you said that if I edit MultiplyNumbers and remove its starting curly brace {`, then all the code below this point will automatically expand.

If so, the problem is that the parser is trying to match the syntax of the language and is looking for any trailing braces under this dot that are in AddNumbers's trailing braces.
Update:
There is no solution to this problem in one line, this is due to the fact that Visual Studio performs parsing in real time, as it shows you errors in real time. In fact, this is not a problem, why it was never reported because of which nothing is available from official sources. However, you can prevent this by changing the coding habits a bit, for example, when you create a function, suppose SomeFunction (int a, int b) tries to complete the outer side of the function first, as shown below;
private void SomeFunction(int a,int b) {
First create a function outline, as described above, and then write the code in it, as shown below:
private void SomeFunction(int a,int b) { int z=a+b; Console.WriteLine(z); int x=a*b; Console.WriteLine(x); int p=a/b; Console.WriteLine(p); int q=ab; Console.WriteLine(q); }
Next, consider what you write if statement , first fill out the outside as follows:
if(
If you used code snippets in Visual Studio, you may have noticed that Visual Studio first creates the outer side of snipett, and then puts the caret in the first argument.
So, these are some recommendations that can prevent the problem.
Now move on to the solution, to prevent this situation when you create a function try to first place its { and } braces before writing any code in it.
Hope this will prevent the problem you are having. If you have anything else, please let me know.