Skip to content

Commit 4404a4a

Browse files
committed
add the new "enablement" config setting
1 parent e24a783 commit 4404a4a

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

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

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { IConfigurationService } from '../../configuration/common/configuration.
77

88
/**
99
* Configuration helper for the `reusable prompts` feature.
10-
* @see {@link CONFIG_KEY}.
10+
* @see {@link CONFIG_KEY} and {@link LOCATIONS_CONFIG_KEY}.
1111
*
1212
* ### Functions
1313
*
14-
* - {@link getValue} allows to current read configuration value
14+
* - {@link getLocationsValue} allows to current read configuration value
1515
* - {@link enabled} allows to check if the feature is enabled
1616
* - {@link promptSourceFolders} gets list of source folders for prompt files
1717
*
@@ -70,20 +70,38 @@ export namespace PromptsConfig {
7070
* Configuration key for the `prompt files` feature (also
7171
* known as `prompt files`, `prompt instructions`, etc.).
7272
*/
73-
export const CONFIG_KEY: string = 'chat.promptFiles';
73+
export const CONFIG_KEY: string = 'chat.reusablePrompts';
74+
75+
/**
76+
* Configuration key for the locations of reusable prompt files.
77+
*/
78+
export const LOCATIONS_CONFIG_KEY: string = 'chat.reusablePrompt.locations';
7479

7580
/**
7681
* Default reusable prompt files source folder.
7782
*/
7883
export const DEFAULT_SOURCE_FOLDER = '.github/prompts';
7984

8085
/**
81-
* Get value of the `prompt files` configuration setting.
86+
* Checks if the feature is enabled.
87+
* @see {@link CONFIG_KEY}.
8288
*/
83-
export const getValue = (
89+
export const enabled = (
90+
configService: IConfigurationService,
91+
): boolean => {
92+
const enabledValue = configService.getValue(CONFIG_KEY);
93+
94+
return asBoolean(enabledValue) ?? false;
95+
};
96+
97+
/**
98+
* Get value of the `reusable prompt locations` configuration setting.
99+
* @see {@link LOCATIONS_CONFIG_KEY}.
100+
*/
101+
export const getLocationsValue = (
84102
configService: IConfigurationService,
85103
): Record<string, boolean> | undefined => {
86-
const configValue = configService.getValue(CONFIG_KEY);
104+
const configValue = configService.getValue(LOCATIONS_CONFIG_KEY);
87105

88106
if (configValue === undefined || configValue === null || Array.isArray(configValue)) {
89107
return undefined;
@@ -111,25 +129,14 @@ export namespace PromptsConfig {
111129
return undefined;
112130
};
113131

114-
/**
115-
* Checks if the feature is enabled.
116-
*/
117-
export const enabled = (
118-
configService: IConfigurationService,
119-
): boolean => {
120-
const value = getValue(configService);
121-
122-
return value !== undefined;
123-
};
124-
125132
/**
126133
* Gets list of source folders for prompt files.
127134
* Defaults to {@link DEFAULT_SOURCE_FOLDER}.
128135
*/
129136
export const promptSourceFolders = (
130137
configService: IConfigurationService,
131138
): string[] => {
132-
const value = getValue(configService);
139+
const value = getLocationsValue(configService);
133140

134141
// note! the `value &&` part handles the `undefined`, `null`, and `false` cases
135142
if (value && (typeof value === 'object')) {

0 commit comments

Comments
 (0)