Skip to content

Commit c20598d

Browse files
committed
refactor: evaluate workspaceConfiguration once
1 parent d296f3d commit c20598d

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/mergeSettings.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const mergeSettingsFromScopes = (
1010
language: string,
1111
packageJson: { contributes: { configuration: { properties: Record<string, any> } } },
1212
) => {
13+
const workspaceConfiguration = vscode.workspace.getConfiguration(process.env.IDS_PREFIX, { languageId: language })
1314
const {
1415
contributes: {
1516
configuration: { properties },
@@ -22,13 +23,17 @@ export const mergeSettingsFromScopes = (
2223
continue
2324
}
2425

25-
const value = getConfigValueFromAllScopes(key as keyof Configuration, language, isObject ? 'object' : 'array')
26+
const value = getConfigValueFromAllScopes(workspaceConfiguration, key as keyof Configuration, isObject ? 'object' : 'array')
2627
lodash.set(settings, key, value)
2728
}
2829
}
2930

30-
const getConfigValueFromAllScopes = <T extends keyof Configuration>(configKey: T, language: string, type: 'array' | 'object'): Configuration[T] => {
31-
const values = { ...vscode.workspace.getConfiguration(process.env.IDS_PREFIX, { languageId: language }).inspect<any[]>(configKey)! }
31+
const getConfigValueFromAllScopes = <T extends keyof Configuration>(
32+
workspaceConfiguration: vscode.WorkspaceConfiguration,
33+
configKey: T,
34+
type: 'array' | 'object',
35+
): Configuration[T] => {
36+
const values = { ...workspaceConfiguration.inspect<any[]>(configKey)! }
3237
const userValueKeys = Object.keys(values).filter(key => key.endsWith('Value') && !key.startsWith('default'))
3338
for (const key of userValueKeys) {
3439
if (values[key] !== undefined) {

0 commit comments

Comments
 (0)