Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i make Visual Studio Code highlight staged changes?

Visual Studio code displays a gutter line to indicate some files have changed. When you stage the changes, the line disappears.

This is what unstaged changes looks like: Unstaged changes in vscode

This is what it looks like after running git add .: Staged changes in vscode

Is there someway to make vscode highlight staged changes in the gutter?

like image 829
Lars Nyström Avatar asked Feb 20 '18 08:02

Lars Nyström


People also ask

How do you see staged changes in VS Code?

The Source Control icon in the Activity Bar on the left will always indicate an overview of how many changes you currently have in your repository. Selecting the icon will show you the details of your current repository changes: CHANGES, STAGED CHANGES and MERGE CHANGES.

How do you highlight in visual codes?

On windows hold down Ctrl + Shift and on mac Command + Shift, then press the key P.


1 Answers

Not natively (VS Code) or with GitLens (GitHub repo)

As you probably know (or written), there is a feature request

Right now, I know which lines are not staged (green for new, blue for edited) and maybe when I commit locally, highlight those lines in a different color (purple?) to represent "committed but unpublished."

But for now, you need to switch to the version control part of VSCode to see what is about to be committed:

uncommitted but staged

There you can inspect staged changes to be committed.

Note: there is an uncommittedColor, but I don't know if it references staged or unstaged changes, or how it is used.
GitLens 6.2 does mention gitlens.gutterUncommittedForegroundColor themable color, but I don't see it anymore in my current 8.3 GitLens version.


The Microsoft/vscode 60389 opened by the OP includes for now:

When you're editing a file in Git, there are three versions of it:

  • HEAD
  • Index
  • Working tree

So, there are two possible diffs to show:

  • HEAD <> Index
  • Index <> Working Tree

We currently show gutter decorations for Index <> Working Tree.
Since the file which is open in the editor is always Working Tree, it doesn't make any sense to show HEAD <> Index changes in the gutter, since none of those two files is Working Tree.


Aug. 202&: Lefty adds in the comments:

In recent GitLens version its possible to temporarily enable this highlighting by pressing Ctrl+Shift+P and entering gitlens.toggleFileChanges.

It disappears on first edit though :(.

like image 62
VonC Avatar answered Oct 06 '22 23:10

VonC