Browse Source

Stops related commit highlighting on initial blame

main
Eric Amodio 5 years ago
parent
commit
286da64261
5 changed files with 38 additions and 16 deletions
  1. +0
    -1
      src/annotations/annotationProvider.ts
  2. +3
    -1
      src/annotations/blameAnnotationProvider.ts
  3. +11
    -5
      src/annotations/gutterBlameAnnotationProvider.ts
  4. +11
    -5
      src/annotations/heatmapBlameAnnotationProvider.ts
  5. +13
    -4
      src/annotations/recentChangesAnnotationProvider.ts

+ 0
- 1
src/annotations/annotationProvider.ts View File

@ -163,7 +163,6 @@ export abstract class AnnotationProviderBase implements Disposable {
this.status = AnnotationStatus.Computed;
if (editor === window.activeTextEditor) {
await setCommandContext(CommandContext.AnnotationStatus, this.status);
await this.selection(editor.selection.active.line);
}
}

+ 3
- 1
src/annotations/blameAnnotationProvider.ts View File

@ -12,7 +12,7 @@ import {
} from 'vscode';
import { Container } from '../container';
import { GitBlame, GitCommit, GitUri } from '../git/gitService';
import { Arrays, Iterables } from '../system';
import { Arrays, Iterables, log } from '../system';
import { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker';
import { AnnotationProviderBase } from './annotationProvider';
import { Annotations, ComputedHeatmap } from './annotations';
@ -58,6 +58,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
return super.onReset(changes);
}
@log({ args: false })
async selection(shaOrLine?: string | number, blame?: GitBlame) {
if (!this.highlightDecoration) return;
@ -106,6 +107,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
return blame;
}
@log({ args: false })
protected getComputedHeatmap(blame: GitBlame): ComputedHeatmap {
const dates = [];

+ 11
- 5
src/annotations/gutterBlameAnnotationProvider.ts View File

@ -5,18 +5,21 @@ import { GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatOptions, GitBlameCommit } from '../git/gitService';
import { Logger } from '../logger';
import { Objects, Strings } from '../system';
import { log, Objects, Strings } from '../system';
import { Annotations } from './annotations';
import { BlameAnnotationProviderBase } from './blameAnnotationProvider';
export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
@log()
async onProvideAnnotation(shaOrLine?: string | number, type?: FileAnnotationType): Promise<boolean> {
const cc = Logger.getCorrelationContext();
this.annotationType = FileAnnotationType.Blame;
const blame = await this.getBlame();
if (blame === undefined) return false;
const start = process.hrtime();
let start = process.hrtime();
const cfg = Container.config.blame;
@ -131,7 +134,11 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
decorationsMap[l.sha] = gutter;
}
Logger.log(cc, `${Strings.getDurationMilliseconds(start)} ms to compute gutter blame annotations`);
if (this.decorations.length) {
start = process.hrtime();
this.editor.setDecorations(this.decoration!, this.decorations);
if (avatars) {
@ -141,12 +148,11 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
this.editor.setDecorations(d.decoration, d.ranges);
}
}
}
Logger.log(`${Strings.getDurationMilliseconds(start)} ms to compute gutter blame annotations`);
Logger.log(cc, `${Strings.getDurationMilliseconds(start)} ms to apply all gutter blame annotations`);
}
this.registerHoverProviders(Container.config.hovers.annotations);
void this.selection(shaOrLine, blame);
return true;
}

+ 11
- 5
src/annotations/heatmapBlameAnnotationProvider.ts View File

@ -4,18 +4,21 @@ import { FileAnnotationType } from '../configuration';
import { Container } from '../container';
import { GitBlameCommit } from '../git/gitService';
import { Logger } from '../logger';
import { Strings } from '../system';
import { log, Strings } from '../system';
import { Annotations } from './annotations';
import { BlameAnnotationProviderBase } from './blameAnnotationProvider';
export class HeatmapBlameAnnotationProvider extends BlameAnnotationProviderBase {
@log()
async onProvideAnnotation(shaOrLine?: string | number, type?: FileAnnotationType): Promise<boolean> {
const cc = Logger.getCorrelationContext();
this.annotationType = FileAnnotationType.Heatmap;
const blame = await this.getBlame();
if (blame === undefined) return false;
const start = process.hrtime();
let start = process.hrtime();
const renderOptions = Annotations.heatmapRenderOptions();
@ -52,14 +55,17 @@ export class HeatmapBlameAnnotationProvider extends BlameAnnotationProviderBase
decorationsMap[l.sha] = heatmap;
}
Logger.log(cc, `${Strings.getDurationMilliseconds(start)} ms to compute heatmap annotations`);
if (this.decorations.length) {
start = process.hrtime();
this.editor.setDecorations(this.decoration!, this.decorations);
}
Logger.log(`${Strings.getDurationMilliseconds(start)} ms to compute heatmap annotations`);
Logger.log(cc, `${Strings.getDurationMilliseconds(start)} ms to apply recent changes annotations`);
}
this.registerHoverProviders(Container.config.hovers.annotations);
void this.selection(shaOrLine, blame);
return true;
}
}

+ 13
- 4
src/annotations/recentChangesAnnotationProvider.ts View File

@ -4,7 +4,7 @@ import { FileAnnotationType } from '../configuration';
import { Container } from '../container';
import { GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Strings } from '../system';
import { log, Strings } from '../system';
import { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker';
import { AnnotationProviderBase } from './annotationProvider';
import { Annotations } from './annotations';
@ -23,7 +23,10 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
this._uri = trackedDocument.uri;
}
@log()
async onProvideAnnotation(shaOrLine?: string | number): Promise<boolean> {
const cc = Logger.getCorrelationContext();
this.annotationType = FileAnnotationType.RecentChanges;
const commit = await Container.git.getRecentLogCommitForFile(this._uri.repoPath, this._uri.fsPath);
@ -32,7 +35,7 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
const diff = await Container.git.getDiffForFile(this._uri, commit.previousSha);
if (diff === undefined) return false;
const start = process.hrtime();
let start = process.hrtime();
const cfg = Container.config;
const dateFormat = cfg.defaultDateFormat;
@ -81,9 +84,15 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
}
}
this.editor.setDecorations(this.decoration, this.decorations);
Logger.log(cc, `${Strings.getDurationMilliseconds(start)} ms to compute recent changes annotations`);
if (this.decorations.length) {
start = process.hrtime();
Logger.log(`${Strings.getDurationMilliseconds(start)} ms to compute recent changes annotations`);
this.editor.setDecorations(this.decoration, this.decorations);
Logger.log(cc, `${Strings.getDurationMilliseconds(start)} ms to apply recent changes annotations`);
}
return true;
}

Loading…
Cancel
Save