mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-17 09:45:36 -05:00
Adds "on" state to file annotation command
Adds "progress" state to file annotation command
This commit is contained in:
@@ -5,6 +5,7 @@ import { AnnotationProviderBase } from './annotationProvider';
|
||||
import { Keyboard, KeyboardScope, KeyCommand, Keys } from '../keyboard';
|
||||
import { TextDocumentComparer, TextEditorComparer } from '../comparers';
|
||||
import { ExtensionKey, IConfig, LineHighlightLocations, themeDefaults } from '../configuration';
|
||||
import { CommandContext, setCommandContext } from '../constants';
|
||||
import { BlameabilityChangeEvent, GitContextTracker, GitService, GitUri } from '../gitService';
|
||||
import { GutterBlameAnnotationProvider } from './gutterBlameAnnotationProvider';
|
||||
import { HoverBlameAnnotationProvider } from './hoverBlameAnnotationProvider';
|
||||
@@ -203,6 +204,8 @@ export class AnnotationController extends Disposable {
|
||||
if (this._annotationProviders.size === 0) {
|
||||
Logger.log(`Remove listener registrations for annotations`);
|
||||
|
||||
await setCommandContext(CommandContext.AnnotationStatus, undefined);
|
||||
|
||||
this._keyboardScope && this._keyboardScope.dispose();
|
||||
this._keyboardScope = undefined;
|
||||
|
||||
@@ -235,7 +238,16 @@ export class AnnotationController extends Disposable {
|
||||
return true;
|
||||
}
|
||||
|
||||
return window.withProgress({ location: ProgressLocation.Window }, async (progress: Progress<{message: string}>) => this._showAnnotationsCore(currentProvider, editor, type, shaOrLine, progress));
|
||||
return window.withProgress({ location: ProgressLocation.Window }, async (progress: Progress<{ message: string }>) => {
|
||||
await setCommandContext(CommandContext.AnnotationStatus, 'computing');
|
||||
|
||||
const computingAnnotations = this._showAnnotationsCore(currentProvider, editor, type, shaOrLine, progress);
|
||||
const result = await computingAnnotations;
|
||||
|
||||
await setCommandContext(CommandContext.AnnotationStatus, result ? 'computed' : undefined);
|
||||
|
||||
return computingAnnotations;
|
||||
});
|
||||
}
|
||||
|
||||
private async _showAnnotationsCore(currentProvider: AnnotationProviderBase | undefined, editor: TextEditor, type: FileAnnotationType, shaOrLine?: string | number, progress?: Progress<{ message: string}>): Promise<boolean> {
|
||||
@@ -311,11 +323,12 @@ export class AnnotationController extends Disposable {
|
||||
this._onDidToggleAnnotations.fire();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
async toggleAnnotations(editor: TextEditor, type: FileAnnotationType, shaOrLine?: string | number): Promise<boolean> {
|
||||
if (!editor || !editor.document || type === FileAnnotationType.RecentChanges ? !this.git.isTrackable(editor.document.uri) : !this.git.isEditorBlameable(editor)) return false;
|
||||
if (!editor || !editor.document || (type === FileAnnotationType.RecentChanges ? !this.git.isTrackable(editor.document.uri) : !this.git.isEditorBlameable(editor))) return false;
|
||||
|
||||
const provider = this._annotationProviders.get(editor.viewColumn || -1);
|
||||
if (provider === undefined) return this.showAnnotations(editor, type, shaOrLine);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
import { Functions } from '../system';
|
||||
// import { Functions } from '../system';
|
||||
import { Disposable, ExtensionContext, TextDocument, TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent, window, workspace } from 'vscode';
|
||||
import { FileAnnotationType } from '../annotations/annotationController';
|
||||
import { TextDocumentComparer } from '../comparers';
|
||||
@@ -43,19 +43,12 @@ import { WhitespaceController } from './whitespaceController';
|
||||
async clear() {
|
||||
if (this.editor !== undefined) {
|
||||
try {
|
||||
if (this.decoration !== undefined) {
|
||||
this.editor.setDecorations(this.decoration, []);
|
||||
}
|
||||
|
||||
if (this.highlightDecoration !== undefined) {
|
||||
this.editor.setDecorations(this.highlightDecoration, []);
|
||||
}
|
||||
|
||||
// I have no idea why the decorators sometimes don't get removed, but if they don't try again with a tiny delay
|
||||
await Functions.wait(1);
|
||||
|
||||
if (this.highlightDecoration === undefined) return;
|
||||
|
||||
this.editor.setDecorations(this.highlightDecoration, []);
|
||||
if (this.decoration !== undefined) {
|
||||
this.editor.setDecorations(this.decoration, []);
|
||||
}
|
||||
}
|
||||
catch (ex) { }
|
||||
|
||||
Reference in New Issue
Block a user