mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-18 09:45:36 -05:00
Closes #138 - adds ignore whitespace setting
This commit is contained in:
@@ -275,6 +275,8 @@ export interface IConfig {
|
||||
};
|
||||
|
||||
blame: {
|
||||
ignoreWhitespace: boolean;
|
||||
|
||||
file: {
|
||||
annotationType: FileAnnotationType;
|
||||
lineHighlight: {
|
||||
|
||||
@@ -177,15 +177,17 @@ export class Git {
|
||||
|
||||
// Git commands
|
||||
|
||||
static blame(repoPath: string | undefined, fileName: string, sha?: string, startLine?: number, endLine?: number) {
|
||||
static blame(repoPath: string | undefined, fileName: string, sha?: string, options: { ignoreWhitespace?: boolean, startLine?: number, endLine?: number } = {}) {
|
||||
const [file, root] = Git.splitPath(fileName, repoPath);
|
||||
|
||||
const params = [`blame`, `--root`, `--incremental`];
|
||||
|
||||
if (startLine != null && endLine != null) {
|
||||
params.push(`-L ${startLine},${endLine}`);
|
||||
if (options.ignoreWhitespace) {
|
||||
params.push('-w');
|
||||
}
|
||||
if (options.startLine != null && options.endLine != null) {
|
||||
params.push(`-L ${options.startLine},${options.endLine}`);
|
||||
}
|
||||
|
||||
if (sha) {
|
||||
params.push(sha);
|
||||
}
|
||||
|
||||
@@ -193,7 +193,14 @@ export class GitService extends Disposable {
|
||||
});
|
||||
}
|
||||
|
||||
const ignoreWhitespace = this.config && this.config.blame.ignoreWhitespace;
|
||||
|
||||
this.config = cfg;
|
||||
|
||||
if (this.config.blame.ignoreWhitespace !== ignoreWhitespace) {
|
||||
this._gitCache.clear();
|
||||
this._fireGitCacheChange();
|
||||
}
|
||||
}
|
||||
|
||||
private _onRemoteProviderChanged() {
|
||||
@@ -428,7 +435,7 @@ export class GitService extends Disposable {
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await Git.blame(root, file, uri.sha);
|
||||
const data = await Git.blame(root, file, uri.sha, { ignoreWhitespace: this.config.blame.ignoreWhitespace });
|
||||
const blame = GitBlameParser.parse(data, root, file);
|
||||
return blame;
|
||||
}
|
||||
@@ -477,7 +484,7 @@ export class GitService extends Disposable {
|
||||
const fileName = uri.fsPath;
|
||||
|
||||
try {
|
||||
const data = await Git.blame(uri.repoPath, fileName, uri.sha, line + 1, line + 1);
|
||||
const data = await Git.blame(uri.repoPath, fileName, uri.sha, { ignoreWhitespace: this.config.blame.ignoreWhitespace, startLine: line + 1, endLine: line + 1 });
|
||||
const blame = GitBlameParser.parse(data, uri.repoPath, fileName);
|
||||
if (blame === undefined) return undefined;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user