Skip to content

Commit c528a95

Browse files
committed
Improved vscode user-defined scope settings
- Previously, the workspace scope was always set, so the user's .vscode/settings.json file had to be constantly modified, which was inconvenient. - Now, users can select and set the scope depending on the situation.
1 parent 93a3ecf commit c528a95

File tree

7 files changed

+499
-126
lines changed

7 files changed

+499
-126
lines changed

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
"title": "Open Configuration UI",
5252
"category": "Quick Commands",
5353
"icon": "$(gear)"
54+
},
55+
{
56+
"command": "quickCommandButtons.toggleConfigurationTarget",
57+
"title": "Toggle Configuration Target (Workspace/Global)",
58+
"category": "Quick Commands"
5459
}
5560
],
5661
"viewsContainers": {
@@ -120,6 +125,16 @@
120125
}
121126
}
122127
},
128+
"quickCommandButtons.configurationTarget": {
129+
"type": "string",
130+
"enum": ["workspace", "global"],
131+
"default": "workspace",
132+
"description": "Where to save button configurations: 'workspace' saves to .vscode/settings.json (project-specific), 'global' saves to user settings (shared across all projects)",
133+
"enumDescriptions": [
134+
"Save to workspace settings (.vscode/settings.json) - project-specific commands",
135+
"Save to user settings - shared across all projects"
136+
]
137+
},
123138
"quickCommandButtons.buttons": {
124139
"type": "array",
125140
"default": [

src/extension/src/main.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,40 @@ export const registerCommands = (
6767
)
6868
);
6969

70+
const toggleConfigurationTargetCommand = vscode.commands.registerCommand(
71+
"quickCommandButtons.toggleConfigurationTarget",
72+
async () => {
73+
const config = vscode.workspace.getConfiguration("quickCommandButtons");
74+
const currentTarget = config.get<string>(
75+
"configurationTarget",
76+
"workspace"
77+
);
78+
const newTarget = currentTarget === "workspace" ? "global" : "workspace";
79+
80+
await config.update(
81+
"configurationTarget",
82+
newTarget,
83+
vscode.ConfigurationTarget.Global
84+
);
85+
86+
const targetMessage =
87+
newTarget === "global"
88+
? "user settings (shared across all projects)"
89+
: "workspace settings (project-specific)";
90+
vscode.window.showInformationMessage(
91+
`Configuration target changed to: ${targetMessage}`
92+
);
93+
}
94+
);
95+
7096
return {
7197
executeCommand,
7298
executeFromTreeCommand,
7399
refreshCommand,
74100
refreshTreeCommand,
75101
showAllCommandsCommand,
76102
openConfigCommand,
103+
toggleConfigurationTargetCommand,
77104
};
78105
};
79106

0 commit comments

Comments
 (0)