From 1d8358f181b5a153d84c13c9e2a1925eadff128d Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 26 Mar 2023 22:45:24 -0400 Subject: [PATCH] Adds storage prefix constant --- src/constants.ts | 1 + src/storage.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index fe1e6d1..47f0319 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,6 @@ export const commandPrefix = 'gitlens'; export const configPrefix = 'gitlens'; +export const storagePrefix = 'gitlens'; export const quickPickTitleMaxChars = 80; export const ImageMimetypes: Record = { diff --git a/src/storage.ts b/src/storage.ts index cf557b6..6f81f50 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -1,6 +1,7 @@ import type { Disposable, Event, ExtensionContext, SecretStorageChangeEvent } from 'vscode'; import { EventEmitter } from 'vscode'; import type { ViewShowBranchComparison } from './config'; +import { storagePrefix } from './constants'; import type { Environment } from './container'; import type { StoredSearchQuery } from './git/search'; import type { Subscription } from './subscription'; @@ -50,18 +51,18 @@ export class Storage implements Disposable { get(key: T, defaultValue: GlobalStorage[T]): GlobalStorage[T]; @debug({ logThreshold: 50 }) get(key: keyof (GlobalStorage & DeprecatedGlobalStorage), defaultValue?: unknown): unknown | undefined { - return this.context.globalState.get(`gitlens:${key}`, defaultValue); + return this.context.globalState.get(`${storagePrefix}:${key}`, defaultValue); } @debug({ logThreshold: 250 }) async delete(key: keyof (GlobalStorage & DeprecatedGlobalStorage)): Promise { - await this.context.globalState.update(`gitlens:${key}`, undefined); + await this.context.globalState.update(`${storagePrefix}:${key}`, undefined); this._onDidChange.fire({ key: key, workspace: false }); } @debug({ args: { 1: false }, logThreshold: 250 }) async store(key: T, value: GlobalStorage[T] | undefined): Promise { - await this.context.globalState.update(`gitlens:${key}`, value); + await this.context.globalState.update(`${storagePrefix}:${key}`, value); this._onDidChange.fire({ key: key, workspace: false }); } @@ -89,18 +90,18 @@ export class Storage implements Disposable { key: keyof (WorkspaceStorage & DeprecatedWorkspaceStorage), defaultValue?: unknown, ): unknown | undefined { - return this.context.workspaceState.get(`gitlens:${key}`, defaultValue); + return this.context.workspaceState.get(`${storagePrefix}:${key}`, defaultValue); } @debug({ logThreshold: 250 }) async deleteWorkspace(key: keyof (WorkspaceStorage & DeprecatedWorkspaceStorage)): Promise { - await this.context.workspaceState.update(`gitlens:${key}`, undefined); + await this.context.workspaceState.update(`${storagePrefix}:${key}`, undefined); this._onDidChange.fire({ key: key, workspace: true }); } @debug({ args: { 1: false }, logThreshold: 250 }) async storeWorkspace(key: keyof WorkspaceStorage, value: unknown | undefined): Promise { - await this.context.workspaceState.update(`gitlens:${key}`, value); + await this.context.workspaceState.update(`${storagePrefix}:${key}`, value); this._onDidChange.fire({ key: key, workspace: true }); } }