Browse Source

Fixes restore of recent changes

main
Eric Amodio 7 years ago
parent
commit
2c3832fd50
5 changed files with 17 additions and 15 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +7
    -6
      src/annotations/annotationController.ts
  3. +5
    -5
      src/annotations/annotationProvider.ts
  4. +2
    -2
      src/annotations/blameAnnotationProvider.ts
  5. +2
    -2
      src/annotations/recentChangesAnnotationProvider.ts

+ 1
- 0
CHANGELOG.md View File

@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#294](https://github.com/eamodio/vscode-gitlens/issues/294) - Keyboard shortcuts will now default to *chorded* to avoid conflicts. FYI, only affects new installs or if you remove the `gitlens.keymap` setting)
- Fixes issue where Recent Changes annotations weren't restored properly on tab switch
## [8.0.2] - 2018-02-19
### Fixed

+ 7
- 6
src/annotations/annotationController.ts View File

@ -24,11 +24,12 @@ export enum AnnotationClearReason {
export const Decorations = {
blameAnnotation: window.createTextEditorDecorationType({
isWholeLine: true,
rangeBehavior: DecorationRangeBehavior.ClosedOpen,
textDecoration: 'none'
} as DecorationRenderOptions),
blameHighlight: undefined as TextEditorDecorationType | undefined,
heatmapAnnotation: window.createTextEditorDecorationType({} as DecorationRenderOptions),
heatmapHighlight: undefined as TextEditorDecorationType | undefined,
recentChangesAnnotation: undefined as TextEditorDecorationType | undefined,
recentChangesHighlight: undefined as TextEditorDecorationType | undefined
};
@ -104,11 +105,11 @@ export class AnnotationController extends Disposable {
}
if (initializing || configuration.changed(e, configuration.name('recentChanges')('highlight').value)) {
Decorations.recentChangesHighlight && Decorations.recentChangesHighlight.dispose();
Decorations.recentChangesAnnotation && Decorations.recentChangesAnnotation.dispose();
const cfgHighlight = cfg.recentChanges.highlight;
Decorations.recentChangesHighlight = window.createTextEditorDecorationType({
Decorations.recentChangesAnnotation = window.createTextEditorDecorationType({
gutterIconSize: 'contain',
isWholeLine: true,
overviewRulerLane: OverviewRulerLane.Right,
@ -141,7 +142,7 @@ export class AnnotationController extends Disposable {
if (provider === undefined) continue;
if (provider.annotationType === FileAnnotationType.RecentChanges) {
provider.reset({ decoration: Decorations.recentChangesAnnotation, highlightDecoration: Decorations.recentChangesHighlight });
provider.reset({ decoration: Decorations.recentChangesAnnotation!, highlightDecoration: Decorations.recentChangesHighlight });
}
else if (provider.annotationType === FileAnnotationType.Blame) {
provider.reset({ decoration: Decorations.blameAnnotation, highlightDecoration: Decorations.blameHighlight });
@ -369,11 +370,11 @@ export class AnnotationController extends Disposable {
break;
case FileAnnotationType.Heatmap:
provider = new HeatmapBlameAnnotationProvider(editor, trackedDocument, Decorations.blameAnnotation, undefined);
provider = new HeatmapBlameAnnotationProvider(editor, trackedDocument, Decorations.heatmapAnnotation, Decorations.heatmapHighlight);
break;
case FileAnnotationType.RecentChanges:
provider = new RecentChangesAnnotationProvider(editor, trackedDocument, undefined, Decorations.recentChangesHighlight!);
provider = new RecentChangesAnnotationProvider(editor, trackedDocument, Decorations.recentChangesAnnotation!, Decorations.recentChangesHighlight);
break;
}
if (provider === undefined || !(await provider.validate())) return undefined;

+ 5
- 5
src/annotations/annotationProvider.ts View File

@ -30,7 +30,7 @@ export abstract class AnnotationProviderBase extends Disposable {
constructor(
public editor: TextEditor,
protected readonly trackedDocument: TrackedDocument<GitDocumentState>,
protected decoration: TextEditorDecorationType | undefined,
protected decoration: TextEditorDecorationType,
protected highlightDecoration: TextEditorDecorationType | undefined
) {
super(() => this.dispose());
@ -97,9 +97,9 @@ export abstract class AnnotationProviderBase extends Disposable {
}
}
private _resetDebounced: ((changes?: { decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined }) => Promise<void>) | undefined;
private _resetDebounced: ((changes?: { decoration: TextEditorDecorationType, highlightDecoration: TextEditorDecorationType | undefined }) => Promise<void>) | undefined;
async reset(changes?: { decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined }) {
async reset(changes?: { decoration: TextEditorDecorationType, highlightDecoration: TextEditorDecorationType | undefined }) {
if (this._resetDebounced === undefined) {
this._resetDebounced = Functions.debounce(this.onReset, 250);
}
@ -107,7 +107,7 @@ export abstract class AnnotationProviderBase extends Disposable {
this._resetDebounced(changes);
}
async onReset(changes?: { decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined }) {
async onReset(changes?: { decoration: TextEditorDecorationType, highlightDecoration: TextEditorDecorationType | undefined }) {
if (changes !== undefined) {
await this.clear();
@ -133,7 +133,7 @@ export abstract class AnnotationProviderBase extends Disposable {
this.document = editor.document;
if (this.decorations !== undefined && this.decorations.length) {
this.editor.setDecorations(this.decoration!, this.decorations);
this.editor.setDecorations(this.decoration, this.decorations);
if (this.additionalDecorations !== undefined && this.additionalDecorations.length) {
for (const d of this.additionalDecorations) {

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

@ -17,7 +17,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
constructor(
editor: TextEditor,
trackedDocument: TrackedDocument<GitDocumentState>,
decoration: TextEditorDecorationType | undefined,
decoration: TextEditorDecorationType,
highlightDecoration: TextEditorDecorationType | undefined
) {
super(editor, trackedDocument, decoration, highlightDecoration);
@ -37,7 +37,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
super.clear();
}
async onReset(changes?: { decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined }) {
async onReset(changes?: { decoration: TextEditorDecorationType, highlightDecoration: TextEditorDecorationType | undefined }) {
if (this.editor !== undefined) {
this._blame = this.editor.document.isDirty
? Container.git.getBlameForFileContents(this._uri, this.editor.document.getText())

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

@ -16,7 +16,7 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
constructor(
editor: TextEditor,
trackedDocument: TrackedDocument<GitDocumentState>,
decoration: TextEditorDecorationType | undefined,
decoration: TextEditorDecorationType,
highlightDecoration: TextEditorDecorationType | undefined
) {
super(editor, trackedDocument, decoration, highlightDecoration);
@ -73,7 +73,7 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
}
}
this.editor.setDecorations(this.highlightDecoration!, this.decorations);
this.editor.setDecorations(this.decoration, this.decorations);
const duration = process.hrtime(start);
Logger.log(`${(duration[0] * 1000) + Math.floor(duration[1] / 1000000)} ms to compute recent changes annotations`);

Loading…
Cancel
Save