New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leave block on single line formatting ineffective without brace completion (regression) #2837
Comments
Oh yes, I knew I filed it somewhere, but was unable to find it! And given the VS is in RC and I am hitting it every day, I thought it might be worth mentioning it at GitHub. |
This is exactly what @miloush claims. We go ahead and format the line on the typing of the ';' key, and the formatting engine has a rule that keeps the block on the same line if it is already on the same line, except is sees it as broken across two lines because the matching brace is on the next line (according to the parser). The reason this worked in prior VS was that we did not do any formatting after the semi-colon key if there were parse errors. Still investigating possible solutions. |
Not attempting to do formatting in the presence of parse errors sounds quite reasonable to me. In general I have to say that the IDE now feels rather aggressive (and the written code less 'stable') whenever there are parse errors. |
I'd second this. I see invalid reformatting all over the place while editing code now. The editor can't wait until I'm done and constantly pushes things around in the wrong direction. If you don't want to disable this new "ability" completely, can there be at least an option in "Text editor; C#; Formatting; General"? |
I noticed another weird behaviour of the VS 2015 editor. When pasting a line with |
Actually, that looks like #2487. |
@CyrusNajmabadi is going to think about this for a while |
Fixed by #4644 |
Running Update 1 RC (24627) and it seems just the example above has been hotfixed. It still messes with e.g.: namespace ConsoleApplication1
{
class Program
{
public static bool One { get|
static void Main(string[] args)
{
}
}
} and wraps it: public static bool One {
get; The same with: public static void Test() { return| I still think it is a good idea to avoid formatting (at least automatic) if there are parse errors. If it helps, I have noticed that if you cancel the autocomplete suggestions of |
Hmm - the fact that it only happens if autocomplete is up means this is actually a different issue. Can you file something new to track it? |
Running Update 2 CTP (25008) and still, try { }
catch { continue| gets wrapped as try { }
catch {
continue; Is that a different issue? This one is not triggered by autocomplete. |
This is a different issue. |
OK, is that being tracked or should I create it? |
You shoudl create it. |
Settings to reproduce:
C# > Formatting > Wrapping > Leave block on single line
on
(on by default)C# > Automatic brace completion
off
(newly on by default)If semicolon is typed at this point, the formatter decides to reformat the block:
Likely because it thinks the next closing bracket belongs to the getter which it does not. This parsing strategy (exhibited in other contexts, too) makes the leave block on single line setting ineffective, and the issue is hit very often during typing and is time consuming to fix.
This was not a problem in previous version of Visual Studio (without brace completion).
The text was updated successfully, but these errors were encountered: