Browse Source

Defers provider reset

main
Eric Amodio 6 years ago
parent
commit
5ba18860cb
2 changed files with 13 additions and 2 deletions
  1. +11
    -0
      src/annotations/annotationProvider.ts
  2. +2
    -2
      src/annotations/blameAnnotationProvider.ts

+ 11
- 0
src/annotations/annotationProvider.ts View File

@ -1,4 +1,5 @@
'use strict';
import { Functions } from '../system';
import { DecorationOptions, Disposable, ExtensionContext, TextDocument, TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent, Uri, window } from 'vscode';
import { FileAnnotationType } from '../annotations/annotationController';
import { TextDocumentComparer } from '../comparers';
@ -79,7 +80,17 @@ export abstract class AnnotationProviderBase extends Disposable {
}
}
private _resetDebounced: ((changes?: { decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined }) => Promise<void>) | undefined;
async reset(changes?: { decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined }) {
if (this._resetDebounced === undefined) {
this._resetDebounced = Functions.debounce(this.onReset, 250);
}
this._resetDebounced(changes);
}
async onReset(changes?: { decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined }) {
if (changes !== undefined) {
await this.clear();

+ 2
- 2
src/annotations/blameAnnotationProvider.ts View File

@ -33,14 +33,14 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
super.clear();
}
async reset(changes?: { decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined }) {
async onReset(changes?: { decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined }) {
if (this.editor !== undefined) {
this._blame = this.editor.document.isDirty
? this.git.getBlameForFileContents(this.uri, this.editor.document.getText())
: this.git.getBlameForFile(this.uri);
}
super.reset(changes);
super.onReset(changes);
}
async selection(shaOrLine?: string | number, blame?: GitBlame) {

Loading…
Cancel
Save