How do i get Visual Studio 2015 to highlight brackets, braces and references instantly, with no delay?
Asked Answered
L

5

11

When placing the curser on a closing bracket in c# for instance, there is a small annoying delay before the opening bracket gets highlighted, and you have to sit and wait before you can use shortcuts such as (ctrl + shift + up/down). It feels like it is intended behaviour for reasons beyond me, so i don't think it is a bug or because my computer is slow (it's not), but it's driving me crazy.

I'm on a freshly installed PC, so i have only testet it in a few programming languages / file formats, and the behaviour only occours in some of them.

The delayed highligh behaviour occurs in .cs (c#), and .css files, but not in .js and .html files, here the code gets highlighed instantaneously exactly like i want it to in .cs files aswell.

I'm using Visual Studio 2015 Community Edition.

Luteous answered 30/7, 2015 at 13:11 Comment(5)
Checked on a fresh install of Windows 10, Visual Studios 2015 Ultimate. Created a empty Windows Form Application, C#. I am unable to produce in detectable delay when selecting the ending brace and the opening brace highlighting. Perhaps the IDE is having trouble finding your matching braces? Odd, never seen or heard of this so I am curious.Bascomb
I too am unable to replicate your problem. Tested on a massive C# code file in VStudio 2015 Community Edition. Perhaps there is a lower level issue?Paigepaik
Hi, strange thats its only happening for some people, i wonder why that is. I just uninstalled VS 2013, and installed VS 2015 again, on two computers, both with windows 10. And its the same for both of them.Luteous
I have the same problem on a fresh Windows 7 VM (VirtualBox) with VS 2015 Enterprise. Really annoying.Ambroid
Maybe related: github.com/dotnet/roslyn/issues/1906Ambroid
N
3

I have had this problem as well, since first installing. I can confirm that Update 1 CTP addresses this issue, and the delay is almost gone (maybe 1/8 second now.)

This UI delay was actually called out as a bugfix that was included with the update:

https://support.microsoft.com/en-us/kb/3025135

Nurmi answered 9/10, 2015 at 19:5 Comment(1)
Yup, can also confirm. I installed VS 2015 again, and downloaded the update manually from microsoft.com/en-us/download/details.aspx?id=49189 Problem is gone.Luteous
P
2

Its about 500ms in a newly created console project

500 msec is a magic number in .NET. You can get some insight from the source code for the C# Language Service, accidentally (?) exposed by a Microsoft programmer on github. Most relevant file is probably this one:

internal interface IBraceMatchingService
{
    Task<BraceMatchingResult?> GetMatchingBracesAsync(Document document,
        int position, CancellationToken cancellationToken = default(CancellationToken));
}

Or in other words, the brace matching service runs as a background task. Such tasks normally run on a thread-pool thread and are subject to scheduling by the threadpool manager. That's where the magic 500 ms number comes into play. The manager attempts to keep the number of executing tp threads down to the number of processor cores available on the machine, the most efficient way to run threads. However, if the existing tp threads take too long to finish their job then the manager assumes that they are bogged down by I/O and allows an extra one to run. It does this once every 500 msec.

So first-order estimate of your problem is that VS has too many active thread-pool threads and they don't complete in a timely manner. Causing the brace matching task to run too late.


Finding out exactly what specific tasks bog it down is technically possible. I can't guarantee success with the Community edition and you'd need a fair amount of insight in how to read thread call stacks to get ahead. Startup another instance of Visual Studio and use Debug > Attach to Process. Pick "devenv.exe" from the list. Let it trundle while it is attempting to find PDB files, then use Debug > Break All.

First place to look is Debug > Windows > Tasks. Pretty unlikely you'll see anything there however, normal is to see none. Next one is Debug > Windows > Threads. You ought to see about 15 active threads back in that window. Hover over their Location column to take a peek at their callstack. Making sense of what you see isn't that simple unfortunately, it will help a lot if you can compare what you see with another machine that does not have this problem.


Since you have this problem on more than one machine, another approach is to look for an environmental factor that they have in common. Things to look for are aggressive anti-malware, a network connection that is too slow or too unreliable, a poorly performing add-in that you like but runs poorly on a VS version it wasn't tested on.

And consider that VS2015 isn't exactly ready for prime-time. Of all the recent VS versions released in the past 18 years, it is probably the least stable. It has a lot of heavy internal changes and there were an unprecedented number of alpha and beta versions with critical bug fixes implemented just a few months ago. Try it again after Update 1 is released.

Polymerization answered 30/7, 2015 at 13:11 Comment(0)
S
2

To the problem that there is a delay highlighting the brackets: In my opinion that has nothing to do with a bug. I think it takes a little while because your code needs to be parsed every time you change something in order to highlight the brackets. When you have many lines of code in one file it is obvious that it takes a little more time than normal.

Here are some tips that may help you:

Click the bracket and press STRG + ´ this will bring you directly to the other bracket. Or you press ALT + ´ and it will mark all your code in between your current brackets. You can look up the shortcuts of Visual Studio in Tools -> Options -> Environment -> Keyboard:

Here are all shortcuts listed and you can modify them as you please

I'd recommend everybody programming in Visual Studio is to change the highlight color of the matching bracket. Have a look at this:

Tools -> Options -> Environment -> Fonts and Colors

Here you can change all the colors and forms used for specific searchterms. I personally use Visual Assist 2015 to highlight my code (that's why I didn't change anything here). It is way more faster than VS itself and comes with a lot more functions like bracket guidelines who will show you the indent level of your brackets. Have a look, maybe you like it:

enter image description here

Schwejda answered 7/8, 2015 at 14:36 Comment(1)
Hi, thanks appriciate the tips. However the size of the project does not affect the duration of the delay. Its about 500ms in a newly created console project with one file, and its the same in a 1000 files+ project.Luteous
A
2

Seems like this will be fixed in a future Visual Studio update: https://github.com/dotnet/roslyn/issues/1906#issuecomment-145874647

Ambroid answered 6/10, 2015 at 14:59 Comment(1)
Nice find! Lets hope :)Luteous
V
1

I have not found a definitive solution for your problem.
This was a known bug in the VS2015 review edition.

This links discusses the delay (this link refers to c# btw, not c):
https://connect.microsoft.com/VisualStudio/feedback/details/1033540/braces-are-not-highlighted-correctly-in-c

And there are still similar problems for some VS2015 Community Edition users.

http://www.developerteacher.com/msdn/bracket-matching-highlights-not-working-like-i-had-in-2013-express-4227

Personally, I think you are stuck with a bug and if I were you I'd try the following:

  1. Make sure I had unistalled all previous editions of VS.
  2. Try a repair.
  3. Completely uninstall and reinstall VS2015 if running repair doesn't work
  4. Go back to VS2013 if it drives you cannot stand it, and wait until VS2015 is a bit more ripe on the vine.

One thing I have found with VS, is when it plays up it's painful, it takes so long to install and the worst case was when I ended up uninstalling and downloading everything that was associated with the install. It now works fine. (this was after previewing 2015 and then going back to 2013). You can also try this for VS2015 and also try a new download.

I sometimes will have a look at some previews, but after jumping in with haste too many times with the latest software releases and then repenting with leisure. I am now happy to wait for new releases to be out for a while before upgrading.

Another FYI for you to browse.

This is a link to Visual Studio 2015 RC fixed bugs and known issues. There are quite a few issues and hacks suggested. (not specific to your problem, but still there a few months ago.).

I am assuming you know how to play around with the settings. I've added the obvious, in case it's been overlooked.

I have added this screen shot from VS2013 settings.

Make sure you have automatic delimeter highlighting checked.

screen shot

Sorry I could not be of more help.

Verbalism answered 7/8, 2015 at 13:41 Comment(1)
Hi, thanks for your research & time. I've just tried installing VS 2015 again on both of my machines. And the issue still occurs, so for now its back to VS 2013Luteous

© 2022 - 2024 — McMap. All rights reserved.