From 286da642613e6e5d5400a31cf5e15fe697e426cd Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 5 Apr 2019 03:42:56 -0400 Subject: [PATCH] Stops related commit highlighting on initial blame --- src/annotations/annotationProvider.ts | 1 - src/annotations/blameAnnotationProvider.ts | 4 +++- src/annotations/gutterBlameAnnotationProvider.ts | 16 +++++++++++----- src/annotations/heatmapBlameAnnotationProvider.ts | 16 +++++++++++----- src/annotations/recentChangesAnnotationProvider.ts | 17 +++++++++++++---- 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/annotations/annotationProvider.ts b/src/annotations/annotationProvider.ts index 5233e64..76a6acc 100644 --- a/src/annotations/annotationProvider.ts +++ b/src/annotations/annotationProvider.ts @@ -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); } } diff --git a/src/annotations/blameAnnotationProvider.ts b/src/annotations/blameAnnotationProvider.ts index 396b1b6..f31d731 100644 --- a/src/annotations/blameAnnotationProvider.ts +++ b/src/annotations/blameAnnotationProvider.ts @@ -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 = []; diff --git a/src/annotations/gutterBlameAnnotationProvider.ts b/src/annotations/gutterBlameAnnotationProvider.ts index 32cc64e..e9a8c60 100644 --- a/src/annotations/gutterBlameAnnotationProvider.ts +++ b/src/annotations/gutterBlameAnnotationProvider.ts @@ -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 { + 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; } diff --git a/src/annotations/heatmapBlameAnnotationProvider.ts b/src/annotations/heatmapBlameAnnotationProvider.ts index 16101e0..8aee28d 100644 --- a/src/annotations/heatmapBlameAnnotationProvider.ts +++ b/src/annotations/heatmapBlameAnnotationProvider.ts @@ -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 { + 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; } } diff --git a/src/annotations/recentChangesAnnotationProvider.ts b/src/annotations/recentChangesAnnotationProvider.ts index 4d1f7d0..2f183d9 100644 --- a/src/annotations/recentChangesAnnotationProvider.ts +++ b/src/annotations/recentChangesAnnotationProvider.ts @@ -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 { + 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; }