Closes #138 - adds ignore whitespace setting

This commit is contained in:
Eric Amodio
2017-09-12 17:46:22 -04:00
parent 6837414f22
commit 543d39246f
6 changed files with 40 additions and 15 deletions

View File

@@ -275,6 +275,8 @@ export interface IConfig {
};
blame: {
ignoreWhitespace: boolean;
file: {
annotationType: FileAnnotationType;
lineHighlight: {

View File

@@ -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);
}

View File

@@ -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;