Browse Source

Watches for blame annotation changes

So that it can hide/restore the hover blame annotation if needed
main
Eric Amodio 7 years ago
parent
commit
ca5845018f
3 changed files with 19 additions and 3 deletions
  1. +5
    -0
      src/blameActiveLineController.ts
  2. +13
    -2
      src/blameAnnotationController.ts
  3. +1
    -1
      src/gitProvider.ts

+ 5
- 0
src/blameActiveLineController.ts View File

@ -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);

+ 13
- 2
src/blameAnnotationController.ts View File

@ -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<void>();
get onDidToggleBlameAnnotations(): Event<void> {
return this._onDidToggleBlameAnnotationsEmitter.event;
}
private _annotationProviders: Map<number, BlameAnnotationProvider> = 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<boolean> {
@ -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 {

+ 1
- 1
src/gitProvider.ts View File

@ -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';

Loading…
Cancel
Save