Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio - how to ALWAYS show pending changes

I've spent most of my time using Eclipse or IntelliJ with the source in a Git repository. I've just started working with Visual Studio with the source from a TFS Server. Version 2015 of each.

I'm not adjusting to the version control differences and am seeking help.

Eclipe / IntelliJ shows change markers in the margin. And although this does not provide enough information about the change, it shows you where changes have been made and you can delve deeper to find further diff information.

VS / TFS shows nothing in the file window. I don't even know a change has been made. To know anything, I have to open the Pending Changes window. In it I can right-click and choose 'compare with ...'. But then when I do the same to a different file, the changes shown for the last one disappear driving me to do the same thing if I want to see it again. Over and over ... I find this workflow very slow. I found Set default action to Compare in Visual Studio 2013 Pending Changes window with TFS that showed you can shift double-click a file to get to the diff view. This saves a bit of time and effort.

Is there a way to improve VS / TFS so the changes to a file are always seen? Much like the editor Track Changes https://www.codeproject.com/articles/109611/color-indicator-for-code-changes-track-changes-in - but that sticks around after a save (until commit).

Visual Studio Track Changes

I had a look through https://marketplace.visualstudio.com/search?term=tfs&target=VS&category=All%20categories&vsVersion=&sortBy=Relevance and I couldn't see anything. Perhaps someone knows of something?


Adding Screenshot for comment below. I discussed how I worked out you can see inline diffs and sometimes you can edit these. I found out why you can't edit them. Because the files are in /Temp. Why VS creates some diffs there and others in the file location I don't know.

enter image description here

like image 371
HankCa Avatar asked Oct 29 '22 02:10

HankCa


2 Answers

There is an extension in the VS Marketplace named TFSPendingChangesMargin. I have found it very useful but it currently only works in VS 2013 and 2015. To make this extension work with release 2 and 3 of Visual Studio 2015, you need to download the vsix from here. Unfortunately, you need to disable automatic updates of this extension, or it will get updated to the version in the marketplace.

The feature I found especially useful was the ability to rollback specific changes in a file. I would love if somebody would update it to work with VS 2017.

like image 162
JapNolt Avatar answered Dec 21 '22 09:12

JapNolt


Manually compare files between different versions is the expected behavior.

If you mean that you want to always show the diff view for each changed file, I think that doesn't make sense. If there are lot's of files changes in a huge project, the compare views will consume much more memory and other hardware resources, that will affect the performance.

For the editor Track Changes you mentioned, you can set it accordingly for your VS, (checked, it's set as default in VS 2015). We can see that, it can identify the changes in the file itself with different color marked. From this point of view, actually achieved that "ALWAYS show pending changes" before check in the changes, then changes are marked as different color in the file.

But for TFS diff views, they are for comparing between different versions. So, they are different. And I think always show the pending changes is not necessary, we just need to compare with previous versions instantly and periodically as needed.

If you want to compare all the file changes together, you can try to get/download the source of different versions to local directory/workspace, then use the compare tools such as BeyondCompare or ExamDiffPro to compare the directories. All the files within the directory will be compared in each diff view.


UPDATE1:

We can set keyboard shortcuts CTRL + ], P to quickly navigate to "Pending Changes", then select the file in the list with shift + double-click to compare them.

To specify or customize keyboard shortcuts in VS:

Tools > Options > Environment > Keyboard , then enter "View.TfsPendingChanges" in the "Show Command containing" text box and the desired shortcut into the Press shortcut keys box (just press the keys you want to map) and finally hit Assign.

enter image description here


UPDATE2:

You can also refer to this article : Comparison keyboard shortcuts for Pending Changes in TFS to set the shortcuts for below comparing:

Enter the command names below into the Show commands containing text box one at a time:

  • TeamFoundationContextMenus.SourceControlPendingChangesSourceFiles.Compare.TfsContextPendingCheckinsCompareWithLatestVersion
  • TeamFoundationContextMenus.SourceControlPendingChangesSourceFiles.Compare.TfsContextPendingCheckinsCompareWithWorkspaceVersion
  • TeamFoundationContextMenus.SourceControlPendingChangesSourceFiles.Compare.TfsContextPendingCheckinsCompareWithPreviousVersion

For each command enter your desired keyboard shortcut into the Press shortcut keys text box and click the Assign button. You can set the shortcut keys as below for each of them, that worked at my side (Based on your shortcut settings for other actions, just do not use the duplicated shortcut with others):

  • Shift+`
  • Ctrl+Shift+`
  • Ctrl+Alt+`

Also as mentioned in HankCa's comment below, if you change to an Inline Diff, then you can see the difference and edit the file. When the code was executing. To get Inline Compare, you can add the Compare Files Toolbar and selected it from one of the drop downs. If you click the 'keep open' icon on the window tab it will remain on screen and you can open multiple diffs / edit windows.

For temp diff file, it's expected behavior, when you change the files, the system will create the TFS temporary diff files in "AppData\Local\Temp\TFSTemp". The files all had names like "vctmp4316_370233.cs"

like image 36
Andy Li-MSFT Avatar answered Dec 21 '22 10:12

Andy Li-MSFT