Incorrect expression of lambda expression

I had this problem for a while in Visual Studio 2013. It seems that she does not understand how to correctly apply the indentation rules to lambda expressions when they were not aligned correctly. Here is a simplified example:

var s = new Action(() => { }); 

In the second and third lines, the indentation is only 3 spaces instead of 4 (the example of the real code is much larger than the internal expression covering hundreds of lines - this was checked by my colleague, and I'm trying to fix it). I tried every combination of reformatting code, document, recreating curly brace, etc. Nothing is working. He refuses to automatically update the indent properly.

I usually didnโ€™t worry about this, but it forces all the code inside to disable 1 character. When I type the lines in the middle, the tab / shift + tab markers have 1 character from the lines above and below, and I constantly have to adapt to line up the elements again. The closest I can find to mention this issue is Connect Feedback from 2013, which is supposedly fixed, but I'm in Update 4 (released in November 2014) and still experiencing the problem.

With the exception of manually jumping and updating the indentation for each line in the lambda expression, does anyone have an idea how I can quickly fix this code?

+6
source share
1 answer

Visual ignoring the problem in Visual Studio and solving the problem right away. Hold alt to enable block selection, select all rows and enter one place. Just to illustrate:

Block selection

If you type Hello World! , the result will be:

After typing

Like "rant": one lambda should not contain hundreds of lines of code, it is very large, but not repairable, wise.

+4
source

Source: https://habr.com/ru/post/979301/


All Articles