CodeLens file activity and history now available for C++, JavaScript and SQL files stored in Git

Mathew Aniyan MSFT

CodeLens makes it easy to explore code changes and other history as you work. It provides a head-up display in Visual Studio editor that shows useful, in-context information about your code. This information, shown as a set of team indicators, tells you when the file was changed, who changed it, and lets you drill down into a vast range of details about the changes.

In previous versions of Visual Studio, CodeLens indicators were available for only C# and Visual Basic files. In Visual Studio 2015 CTP6, CodeLens now shows team indicators for C++, JavaScript, and SQL files. These indicators automatically appear whenever you open a file versioned in a Git repository. While the CodeLens indicators for C# and Visual Basic files are shown at the code element (method, field, or class) level, the new CodeLens indicators for C++, SQL, and JavaScript are shown at the file level. They are positioned in between the horizontal scrollbar and the zoom control in the editor.



In this post, I’ll explore some scenarios that highlight how you can use the CodeLens team indicators for C++, JavaScript, and SQL.

**Note****: All the screenshots below are for the *Azure Mobile Services repository in GitHub. You can clone this yourself to explore the functionality I describe.*

When was the file last changed?

Very often, when you are reviewing a file, you want to know when it was last changed. You can see this directly in the CodeLens indicator.


This file was changed 130 days ago. I’ve found this feature particularly useful for investigating recent changes that caused functional regressions in this code.

Understanding team activity

CodeLens is also useful when you want to understand the team activity for a file. While reviewing a file, you may want to understand the reason for each change that was committed. Previously, you had to go to the Source Control History view to see the list of commits. Now you can click on the author name indicator, and CodeLens displays the Team Activity View—which presents a graphical representation of the commits for this file.


You can see all the commits listed on a timeline, which allows you to understand the history and perhaps discover patterns in the commits based on the dates and the authors that changed the file. The legend on the right maps colors to authors, the first author being the most recent. If there are more than five authors, we group older authors and represent their commits using gray markers.

Team Activity View – feature drilldown

The features in the Team Activity View for CodeLens file-level indicators are identical to those you have now on C# and Visual Basic code-element-level indicators. If you are not familiar with these features, this description of Team Activity View will help:

  • It shows the number of changes committed by each author, distributed across a timeline
  • Each commit is represented by a shape (dot or triangle), with the color representing the author
  • The horizontal axis shows how many days ago the commit occurred
  • The chart is kept readable by drawing the marker shapes above each other where they would otherwise overlap
  • When hovering over a shape, you see a tooltip containing the details of commit.


Then, by right clicking on a shape, you see a shortcut menu that contains in-context actions. For example, you can:

  • View full details about the selected commit
  • Contact the author by email; or by instant messaging, phone, or video chat if Lync is installed
  • Open the author’s contact card


As with other Code Lens indicators, and Visual Studio pop-up windows, you can dock the Team Activity View so that it remains visible. The timeline is expanded to fill the available horizontal space, which may make it easier to see patterns for the commits that occurred around the same dates.



Changes indicator

The Changes View, which appears when you click the changes indicator, provides a different representation of the history of the file. It displays a list of commits made on the file, with the most recent one shown first.


Work items indicator

If you are using work items in Team Foundation Server, along with Git as your version control, CodeLens also displays the work items indicator that shows the number of bugs, features, and user stories associated with the file. When you click this indicator, CodeLens displays the Work Item View containing details of these associated work items.


I find this is useful when I want to locate the documentation related to this file. You can open the work items directly from this view.

Some other feature details

Here’s a few other points of interest for CodeLens team indicators:

  • If you don’t want to see the file-level indicators, collapse them by clicking on the arrow icon at left.


This shows an information symbol instead, and CodeLens no longer processes the file history. Click the arrow icon again to redisplay the indicators.


  • Right-click on the file-level indicators to open the shortcut menu where you can refresh them.


By default, the indicators are automatically refreshed when you commit a change, pull or synchronize from a remote repository, or change the branch.

  • File-level indicators are not turned on for C# and Visual Basic files because the code-element-level indicators provide the same information, but in greater detail.


We are working on enabling CodeLens file-level indicators for files versioned in Team Foundation Version Control. We also plan to enable the file-level indicators for other files that can be opened in the Visual Studio Editor.


As always, we are interested in hearing your feedback on this feature. Try it out and let us know. You can send us your feedback using Visual Studio’s Send a Smile feature. You can also log your feature suggestions on the Visual Studio User Voice site.


Discussion is closed.

Feedback usabilla icon