Browse Source

Fixes issue with line blame toggle not working

When current line blame starts off, the toggle doesn't work
main
Eric Amodio 6 years ago
parent
commit
0884098748
2 changed files with 29 additions and 11 deletions
  1. +24
    -10
      src/annotations/lineAnnotationController.ts
  2. +5
    -1
      src/trackers/gitLineTracker.ts

+ 24
- 10
src/annotations/lineAnnotationController.ts View File

@ -50,18 +50,11 @@ export class LineAnnotationController extends Disposable {
const cfg = configuration.get<IConfig>(); const cfg = configuration.get<IConfig>();
if (cfg.currentLine.enabled) { if (cfg.currentLine.enabled) {
this._enabled = true; this._enabled = true;
Container.lineTracker.start(
this,
Disposable.from(
Container.lineTracker.onDidChangeActiveLines(this.onActiveLinesChanged, this)
)
);
this.resume();
} }
else { else {
this._enabled = false; this._enabled = false;
Container.lineTracker.stop(this);
this.setLineTracker(false);
} }
} }
@ -74,6 +67,8 @@ export class LineAnnotationController extends Disposable {
} }
resume(reason: 'debugging' | 'user' = 'user') { resume(reason: 'debugging' | 'user' = 'user') {
this.setLineTracker(true);
switch (reason) { switch (reason) {
case 'debugging': case 'debugging':
if (this._suspended !== 'user') { if (this._suspended !== 'user') {
@ -94,6 +89,8 @@ export class LineAnnotationController extends Disposable {
} }
suspend(reason: 'debugging' | 'user' = 'user') { suspend(reason: 'debugging' | 'user' = 'user') {
this.setLineTracker(false);
if (this._suspended !== 'user') { if (this._suspended !== 'user') {
this._suspended = reason; this._suspended = reason;
return true; return true;
@ -201,4 +198,21 @@ export class LineAnnotationController extends Disposable {
editor.setDecorations(annotationDecoration, decorations); editor.setDecorations(annotationDecoration, decorations);
} }
}
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);
}
}

+ 5
- 1
src/trackers/gitLineTracker.ts View File

@ -67,8 +67,12 @@ export class GitLineTracker extends LineTracker {
this.trigger('editor'); this.trigger('editor');
} }
isSubscribed(subscriber: any) {
return this._subscriptions.has(subscriber);
}
start(subscriber: any, subscription: Disposable): void { start(subscriber: any, subscription: Disposable): void {
if (this._subscriptions.has(subscriber)) return;
if (this.isSubscribed(subscriber)) return;
this._subscriptions.set(subscriber, subscription); this._subscriptions.set(subscriber, subscription);

Loading…
Cancel
Save