Lars Nyström
Lars Nyström

Reputation: 6373

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 VS Code

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

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

Upvotes: 39

Views: 13162

Answers (1)

VonC
VonC

Reputation: 1324935

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 :(.

Upvotes: 23

Related Questions