Browse Source

Defers provider reset

main
Eric Amodio 7 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'; 'use strict';
import { Functions } from '../system';
import { DecorationOptions, Disposable, ExtensionContext, TextDocument, TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent, Uri, window } from 'vscode'; import { DecorationOptions, Disposable, ExtensionContext, TextDocument, TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent, Uri, window } from 'vscode';
import { FileAnnotationType } from '../annotations/annotationController'; import { FileAnnotationType } from '../annotations/annotationController';
import { TextDocumentComparer } from '../comparers'; 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 }) { 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) { if (changes !== undefined) {
await this.clear(); await this.clear();

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

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

Loading…
Cancel
Save