Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio possible bug for weird bracket behavior

I am writing some C# code with visual studio and I have a weird behavior with brackets. Let's see an example.

First I write this code:

enter image description here

Then when I add a single bracket with AltGr + Shift + [ I get this:

enter image description here

The entire class gets selected. How can I avoid this? The issue came out after the update to the latest version.


I am using the latest version of everything. I have VS 15.8.0, C# 7.3 and the .NET 4.7.2, any idea?

Please note that some times, after a { the entire class gets selected and I am not able to type the closed bracket }.

This happens when I write C++ as well. (like a new Console App). I have tested it right now in an empty project and the issue is here on C++ as well (VS 15.8.0, C++17). I have added a random c++ function to a library of mine and I have this behavior like in C#!


Possible solution

When I get the entire text selected, I press esc and the text gets deselected (plus the cursor is still at the right place). This is annoying AND this wasn't a problem 2 hours ago (when I had the old version).

like image 497
Raffaele Rossi Avatar asked Aug 16 '18 16:08

Raffaele Rossi


1 Answers

I have an Italian keyboard and I can reproduce this behavior after the update. The fact is:

  • AltGr + Shift + { adds an open bracket as expected

  • AltGr + Shift + } selects the entire declaration of the class/struct in which you are creating the method

I wasn't able to find the keyword map that generates this behaviour (under Tools > Environment > Keyboard).

A solution may be the following: be sure that you have the automatic bracket completion enabled (which is already, by default) and type only the open bracket. In this way, when you type { you automatically get the closed bracket.

What if you need to type a } then? Well, you can use Alt + 125 and you'll get the close bracket (open bracket is Alt + 123.

like image 122
Alberto Miola Avatar answered Nov 08 '22 20:11

Alberto Miola