vscode-gitlens icon indicating copy to clipboard operation
vscode-gitlens copied to clipboard

Gutter highlight to diff configurable ref

Open davidnormo opened this issue 2 years ago • 3 comments

First off, thank you for a really valuable extension for vscode 👍

A feature I'd like to see is to be able to configure the ref for the gutter highlight. At the moment the gutter highlight shows only uncommitted changes. Occasionally I'd like to quickly work on a file but only jump to the lines I've changed in a previous commit.

So I'd like to diff from the previous commit e.g. git diff head~1 or diff from the original branch I've branched from e.g. git diff main or just from any old ref I care about at the time. Then I can work on the file and use the mini map to quickly jump to the sections of the file I care about.

I imagine this config to be temporary. If I change branches or commit then it could be reset back to the default behaviour.

Thanks for your consideration

davidnormo avatar Apr 12 '22 09:04 davidnormo

The gutter glyphs for uncommitted changes is provided by VS Code itself, and unfortunately VS Code doesn't let extensions interact/control/provide them. But GitLens does have a "similar" feature that adds somewhat similar (as similar as is possible given what VS Code allows) behavior for committed changes.

You can toggle the "File Changes" annotations (also called Gutter Changes in the settings -- though I'm planning to standardize on File Changes) to highlight the changes with the last commit.

image

Here is a bit more details: https://github.com/gitkraken/vscode-gitlens#gutter-changes-

You can also choose a specific commit to highlight changes for:

image

Let me know if that meets your request.

eamodio avatar Apr 12 '22 22:04 eamodio

Thanks @eamodio

It feels close to what I'm looking for but I can't seem to change the commit to diff against. Is that the "Change base" option?

davidnormo avatar Apr 19 '22 13:04 davidnormo

Thanks @eamodio .

I wanted to set Toggle Changes to default to on for all files.

I followed your post here and the instructions at https://github.com/gitkraken/vscode-gitlens#file-changes-

Adds Toggle File Changes command (gitlens.toggleFileChanges) to toggle the changes annotations on and off

I added json

    "gitlens.toggleFileChanges": true,
    "gitlens.proxy": {
        "gitlens.toggleFileChanges": true,
    }

(I just threw gitlens.toggleFileChanges where it seemed to fit)

But I couldn't get it to be the default. Is it possible to set Toggle Changes as the default?

Currently following the instructions and enabling Toggle Changes per file does work. It's just tedious, I'd prefer it be default.

jtmoon79 avatar Aug 28 '22 06:08 jtmoon79