From 0884098748de4d2f8566e15289950fd617428ae7 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 16 May 2018 12:29:59 -0400 Subject: [PATCH] Fixes issue with line blame toggle not working When current line blame starts off, the toggle doesn't work --- src/annotations/lineAnnotationController.ts | 34 ++++++++++++++++++++--------- src/trackers/gitLineTracker.ts | 6 ++++- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/annotations/lineAnnotationController.ts b/src/annotations/lineAnnotationController.ts index 4d682ac..846ff44 100644 --- a/src/annotations/lineAnnotationController.ts +++ b/src/annotations/lineAnnotationController.ts @@ -50,18 +50,11 @@ export class LineAnnotationController extends Disposable { const cfg = configuration.get(); if (cfg.currentLine.enabled) { this._enabled = true; - - Container.lineTracker.start( - this, - Disposable.from( - Container.lineTracker.onDidChangeActiveLines(this.onActiveLinesChanged, this) - ) - ); + this.resume(); } else { this._enabled = false; - - Container.lineTracker.stop(this); + this.setLineTracker(false); } } @@ -74,6 +67,8 @@ export class LineAnnotationController extends Disposable { } resume(reason: 'debugging' | 'user' = 'user') { + this.setLineTracker(true); + switch (reason) { case 'debugging': if (this._suspended !== 'user') { @@ -94,6 +89,8 @@ export class LineAnnotationController extends Disposable { } suspend(reason: 'debugging' | 'user' = 'user') { + this.setLineTracker(false); + if (this._suspended !== 'user') { this._suspended = reason; return true; @@ -201,4 +198,21 @@ export class LineAnnotationController extends Disposable { editor.setDecorations(annotationDecoration, decorations); } -} \ No newline at end of file + + private setLineTracker(enabled: boolean) { + if (enabled) { + if (!Container.lineTracker.isSubscribed(this)) { + Container.lineTracker.start( + this, + Disposable.from( + Container.lineTracker.onDidChangeActiveLines(this.onActiveLinesChanged, this) + ) + ); + } + + return; + } + + Container.lineTracker.stop(this); + } +} diff --git a/src/trackers/gitLineTracker.ts b/src/trackers/gitLineTracker.ts index d460123..9d6c3b6 100644 --- a/src/trackers/gitLineTracker.ts +++ b/src/trackers/gitLineTracker.ts @@ -67,8 +67,12 @@ export class GitLineTracker extends LineTracker { this.trigger('editor'); } + isSubscribed(subscriber: any) { + return this._subscriptions.has(subscriber); + } + start(subscriber: any, subscription: Disposable): void { - if (this._subscriptions.has(subscriber)) return; + if (this.isSubscribed(subscriber)) return; this._subscriptions.set(subscriber, subscription);