Skip to content

Commit dbdce75

Browse files
committed
conditionally register 'use prompt' command
1 parent a054f1a commit dbdce75

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/vs/platform/prompts/common/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { IConfigurationService } from '../../configuration/common/configuration.js';
7+
import { ContextKeyExpr } from '../../contextkey/common/contextkey.js';
78

89
// TODO: @lego - update the docs
910
// TODO: @lego - update unit tests
@@ -97,6 +98,11 @@ export namespace PromptsConfig {
9798
return asBoolean(enabledValue) ?? false;
9899
};
99100

101+
/**
102+
* TODO: @lego
103+
*/
104+
export const ENABLED_CTX = ContextKeyExpr.equals(`config.${CONFIG_KEY}`, true);
105+
100106
/**
101107
* Get value of the `reusable prompt locations` configuration setting.
102108
* @see {@link LOCATIONS_CONFIG_KEY}.

src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ import { URI } from '../../../../../../base/common/uri.js';
88
import { CHAT_CATEGORY } from '../../actions/chatActions.js';
99
import { IChatWidget, IChatWidgetService } from '../../chat.js';
1010
import { KeyMod, KeyCode } from '../../../../../../base/common/keyCodes.js';
11-
import { Registry } from '../../../../../../platform/registry/common/platform.js';
11+
import { PromptsConfig } from '../../../../../../platform/prompts/common/config.js';
1212
import { IViewsService } from '../../../../../services/views/common/viewsService.js';
1313
import { isPromptFile } from '../../../../../../platform/prompts/common/constants.js';
14-
import { LifecyclePhase } from '../../../../../services/lifecycle/common/lifecycle.js';
1514
import { IEditorService } from '../../../../../services/editor/common/editorService.js';
1615
import { ICommandService } from '../../../../../../platform/commands/common/commands.js';
1716
import { appendToCommandPalette } from '../../../../files/browser/fileActions.contribution.js';
1817
import { ServicesAccessor } from '../../../../../../platform/instantiation/common/instantiation.js';
19-
import { IWorkbenchContributionsRegistry, Extensions } from '../../../../../common/contributions.js';
2018
import { IActiveCodeEditor, isCodeEditor, isDiffEditor } from '../../../../../../editor/browser/editorBrowser.js';
2119
import { KeybindingsRegistry, KeybindingWeight } from '../../../../../../platform/keybinding/common/keybindingsRegistry.js';
2220
import { IChatAttachPromptActionOptions, ATTACH_PROMPT_ACTION_ID } from '../../actions/chatAttachPromptAction/chatAttachPromptAction.js';
@@ -135,6 +133,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
135133
weight: KeybindingWeight.WorkbenchContrib,
136134
primary: COMMAND_KEY_BINDING,
137135
handler: command,
136+
when: PromptsConfig.ENABLED_CTX,
138137
});
139138

140139
/**
@@ -146,10 +145,5 @@ appendToCommandPalette(
146145
title: localize('commands.prompts.use.title', "Use Prompt"),
147146
category: CHAT_CATEGORY,
148147
},
148+
PromptsConfig.ENABLED_CTX,
149149
);
150-
151-
class RunIfEnabled { }
152-
153-
// register the command as a workbench contribution
154-
Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench)
155-
.registerWorkbenchContribution(RunIfEnabled, LifecyclePhase.Eventually);

0 commit comments

Comments
 (0)