Background Color Fix

Free

Fix the behavior of text background colors in the editor in two ways. First, remove the gap in the background color between subsequent lines with the same color. Second, when the background color is at the end of the line, draw the background color to the edge of the view.

(8) Review
Visual Studio
2013, 2012, 2010
Download (11,841)
11/10/2013
0.7
View
E-mail Twitter del.icio.us Digg Facebook
Add to favorites
Description
Reviews (8)
Q and A (6)
Sign in to write a review
Sort by:

by D Monteiro | November 13 2012

Good job!

by Marius Negruțiu | May 14 2011

Five stars!

by Martin Rex | January 18 2011

(Update: v0.3 fixed both issues in record time)

Found this extension yesterday. It is vital to fix some VS2010 UI changes (annoying goofs for my personal taste), and noticed two bugs in v0.2 of this extension:

- after Screen Lock&Unlock the Background Color Fix is no longer active
and the lines of code&comments are again seperated by a white line

- when coloring the background of "String" (which also affects
the argument of preprocessor #include statements), the background
color extension to the right window border does not look
very appealing to my eyes.

(I'm using VS.NET 2010 on WinXP pro 64-bit aka Win2K3(sp2))

by Larry R. Smith | January 04 2011

I installed this because I really dislike the gaps between consecutive comment lines with colored backgrounds. (I was the one who originally complained about this on Microsoft Connects.)

But I agree that losing colorization of user-defined types is a bug that, if at all possible, needs to be fixed.

But I have two more complaints, both about extending the highlight to the end of the view...

1) Not only is it disconcerting, but it loses a the ability to correct the small problem of identifying trailing blanks on a line so they can be deleted. I dislike selecting lines of text and seeing that there are blotches of blanks at the end of a line. A small thing, to be sure, but I like to have as clean source code as possible.

2) The extension overwrites vertical guidelines inside comments. I often write extensive comments at the beginning of a source module, but I have a guideline to let me know when to wrap my text manually so that the text won't wrap when it's printed. But if the comments take up more vertical space than the window can hold, I've lost my guidelines.

by mctainsh | August 31 2010

I love this extension. Just remove the zip extension and double click to install. Had to restart the app but then it worked perfectly. This even fixed the // comment issue that has been arround singe C# came along.

by Ratfink88 | May 02 2010

Brilliant! Exactly what I needed!

by adontz | April 24 2010

Just great extension! Must have.

by ijprest | February 19 2010

Awesome! Just what the doctor ordered.

Sign in to start a discussion


  • Visual Studio 2013 Preview
    5 Posts | Last post September 13, 2013
    • The Background color Fix does not work with Visual Studio 2013 Preview. It is not found via "Extensions and Updates". It cannot be installed via the VSIX.
    • Yeah, I haven't yet gone through the manual task of modifying the SupportedVersions for all my extensions and making sure they still work :-/
      
      Assuming VS2013 still understands the VS2010 schema, you can try this locally, and please let us know if it works!
      
      1) Download the extension
      2) Change the file extension to .zip and unzip the contents
      3) Modify the extension.vsixmanifest, adding a new entry under the SupportedProducts group:
      <SupportedProducts>
        <!-- VS11.0 is here, below it add: -->
        <VisualStudio Version="12.0">
          <Edition>Pro</Edition>
        </VisualStudio>
      </SupportedProducts>
      4) Add everything back to a .zip file, change the extension to .vsix, and open it from explorer
      
    • The installation was successfull. No problems, no error messages. When in VS2013 the extension does work, however not perfectly.
      
      If the extension is not installed, there is a 2 or 3 pixel gap between consecutive comment lines. The gap's color is the current background color (white with my color scheme).
      
      If the extension is installed, there is a unsharp 1 pixel gap between consecutive comment lines. For example, if the comment background color is a dark blue, the gap line will be a light blue.
    • Thanks Michael.
      
      If you want to play around with it, you can try mucking around with the line coordinates/dimensions in this function:
      https://github.com/NoahRic/BackgroundColorFix/blob/master/BackgroundColorVisualManager.cs#L174
      
      I'm really hazy on my WPF, but I'm wondering if the adornment (layer) needs something like SnapsToDevicePixels. An unsharp pixel gap usually points to subpixel accuracy issues :-/ 
    • Strange. I just upgraded to Windows 8.1 and Visual Studio 2013 RC. The problem is gone. There is no gap any longer.
  • Crashes VS 2012 on .sql scripts
    2 Posts | Last post November 02, 2012
    • This add-on will cause the SQL Script editor to crash on opening any .sql script.
      
      Details are posted on the MSDN forum here: 
      
      http://social.msdn.microsoft.com/Forums/en/ssdt/thread/1bb585cb-976c-4456-8a81-f4447ff49c23
    • Yeah, that's a pretty easy bug to write (in the SQL Script editor); the lazy way to implement native interfaces is to Marshal.ThrowExceptionForHR, which breaks for managed consumers of the interface (the exception only gets marshaled back into an hresult for native clients).
      
      I'll go ahead and work around the bug on the extension side. If you want to try it out locally, grab the source here:
      https://github.com/NoahRic/BackgroundColorFix
      
      ...and put a try/catch() { break; } around the GetClassificationType call on  BackgroundColorVisualManager.cs:89.
  • Not nice in aspx files.
    2 Posts | Last post September 03, 2012
    • This is great extension, but looks funny in aspx files. The aspx files have many yellow lines (because some line ends with %>) like a zebra.
      So it would be nice when the extension applies only to code files. (I think the main purpose also to bring back the xml doc background and not more.)
    • Thanks for couple of great add-ins (this one, and Selection Foreground). I was hoping this would fix the issue with the selection background color height being shorter than the line height, which I something introduced by the other extension (Selection Foreground), but with both loaded, I get an exception Visual Studio as soon as I try to select text in the editor:
      
      
        <entry>
          <record>274</record>
          <time>2012/09/03 05:59:12.475</time>
          <type>Error</type>
          <source>Editor or Editor Extension</source>
          <description>System.NullReferenceException: Object reference not set to an instance of an object.&#x000D;&#x000A;   at BackgroundColorFix.BackgroundColorVisualManager.CreateAndAddAdornment(ITextViewLine line, SnapshotSpan span, Brush brush, Boolean extendToRight)&#x000D;&#x000A;   at BackgroundColorFix.BackgroundColorVisualManager.CreateVisuals(ITextViewLine line)&#x000D;&#x000A;   at BackgroundColorFix.BackgroundColorVisualManager.OnLayoutChanged(Object sender, TextViewLayoutChangedEventArgs e)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.RaiseEvent[TArgs](Object sender, EventHandler`1 eventHandlers, TArgs args)</description>
        </entry>
      
  • VS2012 version?
    9 Posts | Last post August 20, 2012
    • Is it planned?
    • I'm hoping to update all my extensions in the future. In the meantime, you can work around it:
      
      1) Download the extension
      2) Change the file extension to .zip and unzip the contents
      3) Modify the extension.vsixmanifest, adding a new entry under the SupportedProducts group:
      <SupportedProducts>
        <!-- VS10.0 is here, below it add: -->
        <VisualStudio Version="11.0">
          <Edition>Pro</Edition>
        </VisualStudio>
      </SupportedProducts>
      4) Add everything back to a .zip file, change the extension to .vsix, and open it from explorer
    • I updated the extension last night to include VS2012 on the supported products list. If it doesn't work for you, please let me know. Thanks!
    • Noah, thanks a lot for your work. Maybe it's because of RC, but I was not able to make colorfix extension to work.
    • I don't have VS2012 to check, but I'll try to borrow a friend's machine to look at it in the future. At this point, my best guesses are around the hacky update logic, e.g. that it assumes a background opacity of 80% from items in the fonts and colors table (https://github.com/NoahRic/BackgroundColorFix/blob/master/BackgroundColorVisualManager.cs). Since I no longer work on VS, I'd have to debug through it to see for sure.
      
      -Noah
    • This extension has been invaluable to my crazy color scheme in VS2010 and the first thing installed along with ItalicComments in VS2012 RTM, although I am also seeing behavior where in VS2012 it now makes the comment background transparent instead of removing the gap lines/extending to the right edge.  Thanks for your efforts!
    • Thanks for providing the source.  Some playing around in the debugger indicates that the 0.8 background opacity is fine and that the problem lies within ITagAggregator.GetTags always returning an empty set, causing the background to be left completely transparent as CreateAndAddAdornment never gets called.  However, just changing the type parameter from the ClassificationTag concrete type to its IClassificationTag interface appears sufficient to fix it, although I've only tested it on my machine.
    • Good catch :) I've updated the extension to 0.6 with that fix, and credited you with it on the extension page. Thanks!
      
      For background: the extension was written before there were interfaces for the different built-in tag types, and I never updated it for VS2010 RTM, since it didn't break anything. VS2012 has a different concrete type (even if it is still ClassificationTag, it has a new implementation assembly, so the types wouldn't match), which is why it fails.
    • Excellent, glad I could help!
  • Blank lines in multiline C-Style-Comments are ignored
    3 Posts | Last post May 07, 2011
    • Thanks for this great addin, it is really great! But i found a small problem: If a source-file contains multiline C-Style-Comments and these comments contain blank lines, the blank lines won't be rendered using the correct background color for comments.
      e.g.:
      // This comment
      //
      // is being rendered correctly...
      
      /*
         ...but this one
      
         is not!
      */
    • I was annoyed by this as well.  I made a quick stab at fixing it a few months back; source available here: http://github.com/ijprest/BackgroundColorFix
      
      My hacked code is pretty awful, and messes up sometimes (I'm not too familiar with the new editor).  But I got it to the point where it worked OK for most of the comments I deal with day-to-day, so I haven't had much incentive to go and make it nicer.
    • Max - it's a side-effect of the hacky way that the extension works :-/
      
      In VS2008's set of interfaces for colorization, languages would provide a specific color attribute for everything past the last character in the line, which the editor would use to do what this extension is doing.  In the new classification API, nobody (yet?) added the ability to explicitly provide such information, so this extension guesses at it by just using the classification type of the last character on each line.  This works in many cases, but can be too aggressive or not aggressive enough, as in this case.
      
      The only really good way to fix it is a change to the product and to add this feature back to VS. If you open a Connect bug (http://connect.microsoft.com/VisualStudio), the product team can take it into consideration for future versions of VS. I know that a connect bug already exists somewhere for it, but a search for "background color" showed 475 results on connect, and I didn't feel like paging through all that :)
      
      -Noah
  • When enabled colours for "User types" are ignored
    7 Posts | Last post January 18, 2011
    • This add-in has the very anoying and, I think, undesired side effect of preventing the colouring of user types as defined in your Tools -> Environment -> Fonts and Colors section.
      
      For example my settings have "User types" set to a nice share of light blue (default).  With the add-in disabled my C# code shows all my types in the configured colour.  Once enabled the syntax highlighting on user types dissapears and they are rendered just as plain text.  This behaviour occurs regardless of "User types" being set to "default" or a user selected colour.
      
      You can temporarily correct this by after starting VS2010 going into "Fonts and colous" and changing the "User types" settings, this will corect the rendering, but ony for the current VS2010 process lifetime.
      
      Cany you fix this please.
    • Hey Pete,  I'm not sure how it would cause that issue, but I'll see if I can reproduce it and fix it.  Sorry for the trouble :(
      
      In the meantime, if you haven't already, could you try disabling any other extensions you have and making sure it still reproduces?
      
      Thanks,
      -Noah
    • Also, just be sure - are you setting the foreground color of user types to light blue, or are you setting the background color?  That'll help me track down the issue.
      
      -Noah
    • I wasn't able to reproduce the issue you saw, but I uploaded a new version with a few miscellaneous fixes that *might* help.  Could you give it a try and let me know if it fixes the issue?  Thanks!
      
      -Noah
    • I can reproduce the issue: it's a conflict between this extension and the productivity power tools extension. If you have custom colors set, have this extension enabled, have the productivity power tools extension enabled AND have the "Colorized Parameter Help" option enabled will cause this issue.
    • Thanks Gibwar, I can reproduce it now.  I have a change that appears to fix the issue by changing some of the event ordering around, which I'll upload in a second.  If it isn't too much trouble, could you download the new version (v0.4) and give it a shot?
      
      Thanks,
      -Noah
    • Looks like it's fixed in 0.4! Both Colored Parameter Help and Background Color Fix are enabled and all of the text is highlighted as expected. It was a minor annoyance that had an easy workaround so I never really investigated it but it is nice that it's fixed. I actually thought it was the PPT extension and didn't think of a conflict until I saw this post.
      
      Thanks Noah!