With copy-paste, sometimes all the methods are developed which are lower than the place of insertion of the code. How to disable this setting? Those. so that when any code is inserted into an arbitrary place, the methods remain minimized.
- The easiest way to fix something in Visual Studio is to post a bug on Microsoft Connect indicating the exact steps. Without zaplyusovannogo bagreporta they do not fix such small things obchyno. - PashaPash ♦
- Alas, my English is tight. If there is a kind person who will post and link here, I will be grateful, and I'm alone. - Alexis
- And if immediately after inserting, press the button or hotkey "fold all"? - Nick Volynkin ♦
- I use the Ctrl + M Ctrl + O combination, but it's a chore when constantly moving across classes. - Alexis
4 answers
All information about hiding code fragments, bookmarks, etc. (so-called outlining) is stored in a * .suo file, all paths in which are absolute. Naturally, when transferring a project, all absolute paths are no longer relevant and the outlining elements disappear.
From the file * .suo it can be understood that it directly stores the structure of all files with a direct indication of line numbers to which one or another outlining element is applied. Obviously, under certain conditions, when inserting a code fragment, line numbers in *. Suo are not recalculated, which leads to a "drop" of all formatting. What kind of "certain conditions" are these, whether they are conceived by developers or are a commonplace bug is a question for a separate study.
PS I tried to insert different code fragments of different sizes right now and came to the conclusion that outlining is not recalculated if the inserted fragment contains one or more open brackets. In all other cases, VS2013 (English) worked correctly and retained the outlining state after the inserted fragment.
PSS If the problem is observed and you are sure that everything is OK with the parentheses, try to create a read-only .suo file before inserting a large piece of code.
- What should do the readonly suo-file help? Will there be irrelevant line numbers after this? - Qwertiy ♦
- We can only guess when and how exactly the line numbers are recalculated. Perhaps the studio (by analogy with intellisense) simply does not have time to analyze a large fragment of the inserted code and for a moment believes that the syntax is incorrect, deleting all the markup after it. In general, to try in this case faster than to argue) - Anatoly Nikolaev
Moved answer from comment
No This is a glitch. Glitches are not configured. Perhaps, in VS 2015 will be repaired. This is if you write on dotnet, for the two languages ​​of which a new compiler has been released. Otherwise it is unlikely. But still hope for the best. But what if?
As far as I know, all the subsequent unfolds only if what is inserted does not give the correct structure. For example, if the closing method is not copied brace.
Although I admit that the question is about some other situation.
- True, but not only that. For example, if you transfer a project to another folder and open it - all methods are open again. And again, you have to fold everything. And there is even no analogue combination: Ctrl + M Ctrl + O (and it’s not perfect, for example, it doesn’t minimize bit enumerations, etc.), which would allow all classes in a project to be immediately collapsed. This is very annoying, especially when the project is large and you are rushing around in different classes. - Alexis
- I'll start the competition. Maybe the developers have already matured a solution to this issue, or any homework. Switching to VS 2015 will not work in my case due to incompatibility of some components. - Alexis
I will answer a little to the side. This dependence on folding methods looks somewhat strange.
I can assume that your problem should be solved by changing the way of orientation in large projects.
For example, ReSharper with its “Go to everything ...” function (Ctrl + N) turned out to be very successful for me. This in many cases (but not all) eliminates the need to fumble according to the project and to endure the inconvenience of deployed methods.
- oneI use CodeLens, but it’s still unpleasant when all methods are revealed, it also makes navigation and visual perception of the class difficult. - Alexis