From 7cefeb2af85929bbd48f8a7326cf89e98df4b048 Mon Sep 17 00:00:00 2001 From: iCrawl Date: Wed, 14 Apr 2021 14:56:15 +0200 Subject: [PATCH] fix: changing files --- package-lock.json | 2 +- package.json | 2 +- src/extension.ts | 21 +++------------------ src/util.ts | 8 +++++++- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0070907..695ffc5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "discord-vscode", - "version": "5.5.0", + "version": "5.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5b1b197..344ad63 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "discord-vscode", "displayName": "Discord Presence", - "version": "5.5.0", + "version": "5.6.0", "description": "Update your discord status with a rich presence.", "private": true, "author": { diff --git a/src/extension.ts b/src/extension.ts index 5629aaf..f5f7b88 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,21 +1,11 @@ const { Client } = require('discord-rpc'); // eslint-disable-line -import { - commands, - ExtensionContext, - StatusBarAlignment, - StatusBarItem, - window, - workspace, - extensions, - debug, -} from 'vscode'; +import { commands, ExtensionContext, StatusBarAlignment, StatusBarItem, window, workspace, debug } from 'vscode'; import throttle from 'lodash-es/throttle'; import { activity } from './activity'; import { CLIENT_ID, CONFIG_KEYS } from './constants'; -import { GitExtension } from './git'; import { log, LogLevel } from './logger'; -import { getConfig } from './util'; +import { getConfig, getGit } from './util'; const statusBarIcon: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left); statusBarIcon.text = '$(pulse) Connecting to Discord...'; @@ -173,12 +163,7 @@ export async function activate(context: ExtensionContext) { } }); - try { - const gitExtension = extensions.getExtension('vscode.git'); - if (!gitExtension?.isActive) { - await gitExtension?.activate(); - } - } catch {} + await getGit(); } export async function deactivate() { diff --git a/src/util.ts b/src/util.ts index 32b9596..aff35a5 100644 --- a/src/util.ts +++ b/src/util.ts @@ -5,6 +5,8 @@ import { KNOWN_EXTENSIONS, KNOWN_LANGUAGES } from './constants'; import { API, GitExtension } from './git'; import { log, LogLevel } from './logger'; +let git: API | null | undefined; + type WorkspaceExtensionConfiguration = WorkspaceConfiguration & { enabled: boolean; detailsIdling: string; @@ -63,7 +65,10 @@ export function resolveFileIcon(document: TextDocument) { } export async function getGit() { - let git: API | undefined; + if (git || git === null) { + return git; + } + try { log(LogLevel.Debug, 'Loading git extension'); const gitExtension = extensions.getExtension('vscode.git'); @@ -73,6 +78,7 @@ export async function getGit() { } git = gitExtension?.exports.getAPI(1); } catch (error) { + git = null; log(LogLevel.Error, `Failed to load git extension, is git installed?; ${error as string}`); }