mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Adds progress indicator for long annotation operations
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Functions, Objects } from '../system';
|
import { Functions, Objects } from '../system';
|
||||||
import { DecorationRenderOptions, Disposable, Event, EventEmitter, ExtensionContext, OverviewRulerLane, TextDocument, TextDocumentChangeEvent, TextEditor, TextEditorDecorationType, TextEditorViewColumnChangeEvent, window, workspace } from 'vscode';
|
import { DecorationRenderOptions, Disposable, Event, EventEmitter, ExtensionContext, OverviewRulerLane, Progress, ProgressLocation, TextDocument, TextDocumentChangeEvent, TextEditor, TextEditorDecorationType, TextEditorViewColumnChangeEvent, window, workspace } from 'vscode';
|
||||||
import { AnnotationProviderBase } from './annotationProvider';
|
import { AnnotationProviderBase } from './annotationProvider';
|
||||||
import { Keyboard, KeyboardScope, KeyCommand, Keys } from '../keyboard';
|
import { Keyboard, KeyboardScope, KeyCommand, Keys } from '../keyboard';
|
||||||
import { TextDocumentComparer, TextEditorComparer } from '../comparers';
|
import { TextDocumentComparer, TextEditorComparer } from '../comparers';
|
||||||
@@ -11,6 +11,7 @@ import { HoverBlameAnnotationProvider } from './hoverBlameAnnotationProvider';
|
|||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { RecentChangesAnnotationProvider } from './recentChangesAnnotationProvider';
|
import { RecentChangesAnnotationProvider } from './recentChangesAnnotationProvider';
|
||||||
import { WhitespaceController } from './whitespaceController';
|
import { WhitespaceController } from './whitespaceController';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
export type FileAnnotationType = 'gutter' | 'hover' | 'recentChanges';
|
export type FileAnnotationType = 'gutter' | 'hover' | 'recentChanges';
|
||||||
export const FileAnnotationType = {
|
export const FileAnnotationType = {
|
||||||
@@ -234,15 +235,35 @@ export class AnnotationController extends Disposable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return window.withProgress({ location: ProgressLocation.Window }, async (progress: Progress<{message: string}>) => this._showAnnotationsCore(currentProvider, editor, type, shaOrLine, progress));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _showAnnotationsCore(currentProvider: AnnotationProviderBase | undefined, editor: TextEditor, type: FileAnnotationType, shaOrLine?: string | number, progress?: Progress<{ message: string}>): Promise<boolean> {
|
||||||
|
if (progress !== undefined) {
|
||||||
|
let annotationsLabel = 'annotations';
|
||||||
|
switch (type) {
|
||||||
|
case FileAnnotationType.Gutter:
|
||||||
|
case FileAnnotationType.Hover:
|
||||||
|
annotationsLabel = 'blame annotations';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FileAnnotationType.RecentChanges:
|
||||||
|
annotationsLabel = 'recent changes annotations';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
progress!.report({ message: `Computing ${annotationsLabel} for ${path.basename(editor.document.fileName)}` });
|
||||||
|
}
|
||||||
|
|
||||||
// Allows pressing escape to exit the annotations
|
// Allows pressing escape to exit the annotations
|
||||||
if (this._keyboardScope === undefined) {
|
if (this._keyboardScope === undefined) {
|
||||||
this._keyboardScope = await Keyboard.instance.beginScope({
|
this._keyboardScope = await Keyboard.instance.beginScope({
|
||||||
escape: {
|
escape: {
|
||||||
onDidPressKey: (key: Keys) => {
|
onDidPressKey: (key: Keys) => {
|
||||||
const editor = window.activeTextEditor;
|
const e = window.activeTextEditor;
|
||||||
if (editor === undefined) return Promise.resolve(undefined);
|
if (e === undefined) return Promise.resolve(undefined);
|
||||||
|
|
||||||
this.clear(editor.viewColumn || -1);
|
this.clear(e.viewColumn || -1);
|
||||||
return Promise.resolve(undefined);
|
return Promise.resolve(undefined);
|
||||||
}
|
}
|
||||||
} as KeyCommand
|
} as KeyCommand
|
||||||
|
|||||||
Reference in New Issue
Block a user