diff --git a/src/blameActiveLineController.ts b/src/blameActiveLineController.ts index 84192d3..d8802ce 100644 --- a/src/blameActiveLineController.ts +++ b/src/blameActiveLineController.ts @@ -40,6 +40,7 @@ export default class BlameActiveLineController extends Disposable { subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this)); subscriptions.push(git.onDidRemoveCacheEntry(this._onRemoveCacheEntry, this)); + subscriptions.push(annotationController.onDidToggleBlameAnnotations(this._onBlameAnnotationToggled, this)); this._disposable = Disposable.from(...subscriptions); } @@ -105,6 +106,10 @@ export default class BlameActiveLineController extends Disposable { this._onActiveTextEditorChanged(window.activeTextEditor); } + private _onBlameAnnotationToggled() { + this._onActiveTextEditorChanged(window.activeTextEditor); + } + private _onRemoveCacheEntry() { this._blame = undefined; this._onActiveTextEditorChanged(window.activeTextEditor); diff --git a/src/blameAnnotationController.ts b/src/blameAnnotationController.ts index 3f15960..90080ba 100644 --- a/src/blameAnnotationController.ts +++ b/src/blameAnnotationController.ts @@ -1,6 +1,6 @@ 'use strict'; import { Functions } from './system'; -import { DecorationRenderOptions, Disposable, ExtensionContext, OverviewRulerLane, TextDocument, TextEditor, TextEditorDecorationType, TextEditorViewColumnChangeEvent, window, workspace } from 'vscode'; +import { DecorationRenderOptions, Disposable, Event, EventEmitter, ExtensionContext, OverviewRulerLane, TextDocument, TextEditor, TextEditorDecorationType, TextEditorViewColumnChangeEvent, window, workspace } from 'vscode'; import { BlameAnnotationProvider } from './blameAnnotationProvider'; import { TextDocumentComparer, TextEditorComparer } from './comparers'; import { IBlameConfig } from './configuration'; @@ -21,6 +21,11 @@ export let highlightDecoration: TextEditorDecorationType; export default class BlameAnnotationController extends Disposable { + private _onDidToggleBlameAnnotationsEmitter = new EventEmitter(); + get onDidToggleBlameAnnotations(): Event { + return this._onDidToggleBlameAnnotationsEmitter.event; + } + private _annotationProviders: Map = new Map(); private _blameAnnotationsDisposable: Disposable; private _config: IBlameConfig; @@ -138,6 +143,8 @@ export default class BlameAnnotationController extends Disposable { this._blameAnnotationsDisposable && this._blameAnnotationsDisposable.dispose(); this._blameAnnotationsDisposable = undefined; } + + this._onDidToggleBlameAnnotationsEmitter.fire(); } async showBlameAnnotation(editor: TextEditor, shaOrLine?: string | number): Promise { @@ -170,7 +177,11 @@ export default class BlameAnnotationController extends Disposable { } this._annotationProviders.set(editor.viewColumn || -1, provider); - return provider.provideBlameAnnotation(shaOrLine); + if (await provider.provideBlameAnnotation(shaOrLine)) { + this._onDidToggleBlameAnnotationsEmitter.fire(); + return true; + } + return false; } isAnnotating(editor: TextEditor): boolean { diff --git a/src/gitProvider.ts b/src/gitProvider.ts index ceb5db0..4b5f824 100644 --- a/src/gitProvider.ts +++ b/src/gitProvider.ts @@ -1,5 +1,5 @@ 'use strict'; -import { /*Functions,*/ Iterables, Objects } from './system'; +import { Iterables, Objects } from './system'; import { Disposable, Event, EventEmitter, ExtensionContext, languages, Location, Position, Range, TextDocument, TextEditor, Uri, workspace } from 'vscode'; import { CodeLensVisibility, IConfig } from './configuration'; import { DocumentSchemes, WorkspaceState } from './constants';