From c8f6cc84d6d95f0a281a547d9bc859e033e635e6 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 7 Feb 2023 02:41:23 -0500 Subject: [PATCH] Removes Directive namespace --- src/commands/gitCommands.ts | 4 ++-- src/commands/quickCommand.ts | 4 ++-- src/quickpicks/items/directive.ts | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/commands/gitCommands.ts b/src/commands/gitCommands.ts index a015b10..82619fa 100644 --- a/src/commands/gitCommands.ts +++ b/src/commands/gitCommands.ts @@ -4,7 +4,7 @@ import { configuration } from '../configuration'; import { Commands } from '../constants'; import { Container } from '../container'; import type { KeyMapping } from '../keyboard'; -import { Directive, DirectiveQuickPickItem } from '../quickpicks/items/directive'; +import { Directive, DirectiveQuickPickItem, isDirective } from '../quickpicks/items/directive'; import { command } from '../system/command'; import { log } from '../system/decorators/log'; import type { Deferred } from '../system/promise'; @@ -295,7 +295,7 @@ export class GitCommandsCommand extends Command { const result = await step.show(step); if (result === StepResult.Break) return undefined; - if (Directive.is(result)) { + if (isDirective(result)) { switch (result) { case Directive.Back: return (await commandsStep?.command?.previous()) ?? commandsStep; diff --git a/src/commands/quickCommand.ts b/src/commands/quickCommand.ts index baa7b91..62b590d 100644 --- a/src/commands/quickCommand.ts +++ b/src/commands/quickCommand.ts @@ -2,7 +2,7 @@ import type { InputBox, QuickInputButton, QuickPick, QuickPickItem } from 'vscod import { configuration } from '../configuration'; import type { Container } from '../container'; import type { Keys } from '../keyboard'; -import { Directive, DirectiveQuickPickItem } from '../quickpicks/items/directive'; +import { Directive, DirectiveQuickPickItem, isDirective } from '../quickpicks/items/directive'; export * from './quickCommand.buttons'; export * from './quickCommand.steps'; @@ -298,7 +298,7 @@ export namespace QuickCommand { result: Directive | StepItemType, ): result is StepItemType { if (result == null) return false; - if (Directive.is(result)) { + if (isDirective(result)) { switch (result) { case Directive.Back: state.counter--; diff --git a/src/quickpicks/items/directive.ts b/src/quickpicks/items/directive.ts index 8bc3748..32c61d0 100644 --- a/src/quickpicks/items/directive.ts +++ b/src/quickpicks/items/directive.ts @@ -13,10 +13,8 @@ export enum Directive { StartPreviewTrial, } -export namespace Directive { - export function is(value: Directive | T): value is Directive { - return typeof value === 'number' && Directive[value] != null; - } +export function isDirective(value: Directive | T): value is Directive { + return typeof value === 'number' && Directive[value] != null; } export interface DirectiveQuickPickItem extends QuickPickItem {