From 3be416faf0731fdb946109c39130482f879b71f6 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 3 Nov 2017 13:14:42 -0400 Subject: [PATCH] Delays the custom view to improve startup time --- CHANGELOG.md | 1 + package.json | 2 +- src/commands.ts | 4 +++- src/constants.ts | 1 + src/extension.ts | 15 ++++++++------- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbb8451..990dbd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ ATTENTION! To support multi-root workspaces some underlying fundamentals had to - Optimizes event handling, executing git commands, and general processing to improve performance and reduce any lag - Optimizes current line hover annotations to only be computed on hover (i.e. lazily evaluated) to reduce the compute required when changing lines - Protects credentials from possibly being affected by poor network conditions via Git Credential Manager (GCM) for Windows environment variables +- Delays (slightly) the initial loading of the `GitLens` custom view to improve startup performance ### Fixed - Fixes jumpy code lens when deleting characters from a line with a Git code lens diff --git a/package.json b/package.json index cd73a48..f727e5a 100644 --- a/package.json +++ b/package.json @@ -2162,7 +2162,7 @@ { "id": "gitlens.gitExplorer", "name": "GitLens", - "when": "gitlens:enabled && gitlens:hasRepository && config.gitlens.gitExplorer.enabled" + "when": "gitlens:enabled && gitlens:gitExplorer && gitlens:hasRepository && config.gitlens.gitExplorer.enabled" } ] } diff --git a/src/commands.ts b/src/commands.ts index 433c243..bb5b3a8 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,5 +1,5 @@ 'use strict'; -import { ExtensionContext } from 'vscode'; +import { commands, ExtensionContext } from 'vscode'; import { AnnotationController } from './annotations/annotationController'; import { CurrentLineController } from './currentLineController'; import { CodeLensController } from './codeLensController'; @@ -58,6 +58,8 @@ export function configureCommands( currentLineController: CurrentLineController, codeLensController: CodeLensController ): void { + context.subscriptions.push(commands.registerTextEditorCommand('gitlens.computingFileAnnotations', () => { })); + context.subscriptions.push(new Commands.CloseUnchangedFilesCommand(git)); context.subscriptions.push(new Commands.OpenChangedFilesCommand(git)); context.subscriptions.push(new Commands.ExternalDiffCommand(git)); diff --git a/src/constants.ts b/src/constants.ts index fa28123..a900f4f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -28,6 +28,7 @@ export enum CommandContext { AnnotationStatus = 'gitlens:annotationStatus', CanToggleCodeLens = 'gitlens:canToggleCodeLens', Enabled = 'gitlens:enabled', + GitExplorer = 'gitlens:gitExplorer', GitExplorerAutoRefresh = 'gitlens:gitExplorer:autoRefresh', GitExplorerFilesLayout = 'gitlens:gitExplorer:files:layout', GitExplorerView = 'gitlens:gitExplorer:view', diff --git a/src/extension.ts b/src/extension.ts index 26d07d5..d00a37f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,5 @@ 'use strict'; -// import { Objects } from './system'; -import { commands, ExtensionContext, extensions, languages, window, workspace } from 'vscode'; +import { ExtensionContext, extensions, languages, window, workspace } from 'vscode'; import { AnnotationController } from './annotations/annotationController'; import { CodeLensLocations, Configuration, IConfig, LineHighlightLocations } from './configuration'; import { ApplicationInsightsKey, CommandContext, ExtensionKey, GlobalState, QualifiedExtensionId, setCommandContext } from './constants'; @@ -66,23 +65,25 @@ export async function activate(context: ExtensionContext) { const annotationController = new AnnotationController(context, git, gitContextTracker); context.subscriptions.push(annotationController); - const codeLensController = new CodeLensController(context, git, gitContextTracker); - context.subscriptions.push(codeLensController); - const currentLineController = new CurrentLineController(context, git, gitContextTracker, annotationController); context.subscriptions.push(currentLineController); - context.subscriptions.push(new Keyboard()); + const codeLensController = new CodeLensController(context, git, gitContextTracker); + context.subscriptions.push(codeLensController); context.subscriptions.push(workspace.registerTextDocumentContentProvider(GitContentProvider.scheme, new GitContentProvider(context, git))); context.subscriptions.push(languages.registerCodeLensProvider(GitRevisionCodeLensProvider.selector, new GitRevisionCodeLensProvider(context, git))); context.subscriptions.push(window.registerTreeDataProvider('gitlens.gitExplorer', new GitExplorer(context, git))); - context.subscriptions.push(commands.registerTextEditorCommand('gitlens.computingFileAnnotations', () => { })); + + context.subscriptions.push(new Keyboard()); configureCommands(context, git, annotationController, currentLineController, codeLensController); // Constantly over my data cap so stop collecting initialized event // Telemetry.trackEvent('initialized', Objects.flatten(cfg, 'config', true)); + + // Slightly delay enabling the explorer to not stop the rest of GitLens from being usable + setTimeout(() => setCommandContext(CommandContext.GitExplorer, true), 1000); } // this method is called when your extension is deactivated