Skip to content

Commit 543d392

Browse files
committed
Closes #138 - adds ignore whitespace setting
1 parent 6837414 commit 543d392

File tree

6 files changed

+40
-15
lines changed

6 files changed

+40
-15
lines changed

CHANGELOG.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,19 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
5858
- Quickly switch between views using the `Switch to Repository View` or `Switch to History View` commands
5959
- Provides toolbar commands to `Search Commits`, `Switch to Repository View` or `Switch to History View`, and `Refresh`
6060

61-
- Adds command-links to the `details` hover annotation
62-
- Clicking the commit id will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
63-
- Adds command-links to the `changes` hover annotation
64-
- Clicking on `Changes` will run the `Compare File Revisions` command (`gitlens.diffWith`)
65-
- Clicking the current and previous commit ids will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
66-
- Adds support for remote services with custom domains - see [#120](https://github.com/eamodio/vscode-gitlens/issues/120)
67-
- Adds support for the Bitbucket Server (previously called Stash) remote service - see [#120](https://github.com/eamodio/vscode-gitlens/issues/120)
61+
- Adds all-new interactivity to the hover annotations
62+
63+
![Hover Annotations](https://raw.githubusercontent.com/eamodio/vscode-gitlens/develop/images/screenshot-line-blame-annotations.png)
64+
65+
- Adds the following command-links to the `details` hover annotation
66+
- Clicking the commit id will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
67+
- Adds the following command-links to the `changes` hover annotation
68+
- Clicking on `Changes` will run the `Compare File Revisions` command (`gitlens.diffWith`)
69+
- Clicking the current and previous commit ids will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
70+
71+
- Adds support for remote services with custom domains -- closes [#120](https://github.com/eamodio/vscode-gitlens/issues/120)
72+
- Adds support for the Bitbucket Server (previously called Stash) remote service -- closes [#120](https://github.com/eamodio/vscode-gitlens/issues/120)
73+
- Adds `gitlens.blame.ignoreWhitespace` setting to specify whether or not to ignore whitespace when comparing revisions during blame operations -- closes [#138](https://github.com/eamodio/vscode-gitlens/issues/138)
6874
- Adds `Compare File Revisions` command (`gitlens.diffWith`) - compares the specified file revisions
6975
- Adds `Open Branches in Remote` command (`gitlens.openBranchesInRemote`) - opens the branches in the supported remote service
7076
- Adds `Stash Changes` command (`gitlens.stashSave`) to the source control group context menu -- can now stash a group of files
@@ -97,7 +103,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
97103
- Fixes an issue where double hover annotations could be shown on blank lines
98104
- Fixes an issue where remote branches couldn't be opened properly in their remote service
99105
- Fixes [#130](https://github.com/eamodio/vscode-gitlens/issues/130) - First-run "Thank you for choosing GitLens! [...]" info message shown on every start up
100-
- Fixes [#120](https://github.com/eamodio/vscode-gitlens/issues/120) - Feature Request: "Open in Remote" support for custom repositories
101106
- Fixes an issue where sometimes diffs (via branch name) wouldn't open properly
102107
- Fixes an issue where remotes are queried more than once on startup
103108

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,11 @@ GitLens is highly customizable and provides many configuration settings to allow
287287
|`gitlens.insiders`|Opts into the insiders channel -- provides access to upcoming features
288288
|`gitlens.outputLevel`|Specifies how much (if any) output will be sent to the GitLens output channel
289289

290-
### Blame Annotation Settings
290+
### Blame Settings
291+
292+
|Name | Description
293+
|-----|------------
294+
|`gitlens.blame.ignoreWhitespace`|Specifies whether or not to ignore whitespace when comparing revisions during blame operations
291295

292296
#### File Blame Annotation Settings
293297

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@
172172
"default": false,
173173
"description": "Specifies whether or not to trigger hover annotations over the whole line"
174174
},
175+
"gitlens.blame.ignoreWhitespace": {
176+
"type": "boolean",
177+
"default": false,
178+
"description": "Specifies whether or not to ignore whitespace when comparing revisions during blame operations"
179+
},
175180
"gitlens.blame.file.annotationType": {
176181
"type": "string",
177182
"default": "gutter",

src/configuration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ export interface IConfig {
275275
};
276276

277277
blame: {
278+
ignoreWhitespace: boolean;
279+
278280
file: {
279281
annotationType: FileAnnotationType;
280282
lineHighlight: {

src/git/git.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,17 @@ export class Git {
177177

178178
// Git commands
179179

180-
static blame(repoPath: string | undefined, fileName: string, sha?: string, startLine?: number, endLine?: number) {
180+
static blame(repoPath: string | undefined, fileName: string, sha?: string, options: { ignoreWhitespace?: boolean, startLine?: number, endLine?: number } = {}) {
181181
const [file, root] = Git.splitPath(fileName, repoPath);
182182

183183
const params = [`blame`, `--root`, `--incremental`];
184184

185-
if (startLine != null && endLine != null) {
186-
params.push(`-L ${startLine},${endLine}`);
185+
if (options.ignoreWhitespace) {
186+
params.push('-w');
187+
}
188+
if (options.startLine != null && options.endLine != null) {
189+
params.push(`-L ${options.startLine},${options.endLine}`);
187190
}
188-
189191
if (sha) {
190192
params.push(sha);
191193
}

src/gitService.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,14 @@ export class GitService extends Disposable {
193193
});
194194
}
195195

196+
const ignoreWhitespace = this.config && this.config.blame.ignoreWhitespace;
197+
196198
this.config = cfg;
199+
200+
if (this.config.blame.ignoreWhitespace !== ignoreWhitespace) {
201+
this._gitCache.clear();
202+
this._fireGitCacheChange();
203+
}
197204
}
198205

199206
private _onRemoteProviderChanged() {
@@ -428,7 +435,7 @@ export class GitService extends Disposable {
428435
}
429436

430437
try {
431-
const data = await Git.blame(root, file, uri.sha);
438+
const data = await Git.blame(root, file, uri.sha, { ignoreWhitespace: this.config.blame.ignoreWhitespace });
432439
const blame = GitBlameParser.parse(data, root, file);
433440
return blame;
434441
}
@@ -477,7 +484,7 @@ export class GitService extends Disposable {
477484
const fileName = uri.fsPath;
478485

479486
try {
480-
const data = await Git.blame(uri.repoPath, fileName, uri.sha, line + 1, line + 1);
487+
const data = await Git.blame(uri.repoPath, fileName, uri.sha, { ignoreWhitespace: this.config.blame.ignoreWhitespace, startLine: line + 1, endLine: line + 1 });
481488
const blame = GitBlameParser.parse(data, uri.repoPath, fileName);
482489
if (blame === undefined) return undefined;
483490

0 commit comments

Comments
 (0)