Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Commit fff7921

Browse files
committed
refactor(settings): refactored removal of files.exclude value from workspace settings
1 parent 2a701ed commit fff7921

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/extension.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@ const enableCommand = async () => {
2525

2626
function hideNodeModules(hidden: boolean): void {
2727
const config = vscode.workspace.getConfiguration();
28-
const excluded: Excluded = config.get(EXCLUDE, {});
28+
const excludedSettings: Excluded = config.get(EXCLUDE, {});
2929

3030
if (getUserSetting()) {
31-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
32-
const { [NODE_MODULES]: value, ...withouthNodeModules }: Excluded = config.get(EXCLUDE, {});
33-
config.update(EXCLUDE, withouthNodeModules, vscode.ConfigurationTarget.Workspace);
31+
const workspaceExcludedSettings: Excluded = config.get(EXCLUDE, {});
32+
const cleanWorkspaceSettings: Excluded = Object.keys(workspaceExcludedSettings)
33+
.filter((prop) => prop !== NODE_MODULES)
34+
.reduce((obj: Excluded, key: string) => {
35+
obj[key] = workspaceExcludedSettings[key];
36+
return obj;
37+
}, {});
38+
39+
config.update(EXCLUDE, cleanWorkspaceSettings, vscode.ConfigurationTarget.Workspace);
3440
}
3541

36-
excluded[NODE_MODULES] = hidden;
37-
config.update(EXCLUDE, excluded, getUserSetting() ? vscode.ConfigurationTarget.Global : null);
42+
excludedSettings[NODE_MODULES] = hidden;
43+
config.update(EXCLUDE, excludedSettings, getUserSetting() ? vscode.ConfigurationTarget.Global : null);
3844
vscode.commands.executeCommand('setContext', 'hide-node-modules:isHidden', hidden);
3945
toggleStatusBar(hidden);
4046
}

0 commit comments

Comments
 (0)