Open momiccioli opened 4 years ago
That's a duplicate of #7. However I'm interested as well, because the answer in that other issue seems incomplete: Just putting the VSCode command in "command" is not enough. It tries to run the command in the terminal instead.
Here's a basic example that would open settings on click.
"actionButtons": {
"defaultColor": "#172c3d", // Can also use string color names.
"reloadButton": null, // Custom reload button text or icon (default ↻). null value enables automatic reload on configuration change
"commands": [
{
"name": "Settings",
"color": "#ffffff",
"command": "workbench.action.openSettings",
}
]
}
What am I missing?
In order to achieve this, we would have to use the vscode.commands.executeCommands
api
as stated here: https://code.visualstudio.com/api/extension-guides/command,
happy to provide mentoring if anyone is interested in picking this up.
So that means it's not possible yet without modifying the extension itself? Just to make it clear, because the answer on the previous issue made it sound like it was already possible.
In order to achieve this, we would have to use the
vscode.commands.executeCommands
API
At the time, this API didn't exist.
I get that, but that means before the API the extension natively executed commands? The other posted asked if it was possible to call a palette command and you said it was possible as long as we knew the actual command. Is it not possible anymore?
@seunlanlege I think I might me willing to tackle this. I am good with js, have not done much with ts. I did go through the vscode extension tutorial for a js extension. Pretty straight forward. I read the command api page. I see the example:
let uri = Uri.file('/some/path/to/folder');
let success = await commands.executeCommand('vscode.openFolder', uri);
Thinking out loud here, the process would be:
add the 'vsCommand' property to package.json
in init.ts line 49, pass the 'vsCommand' read from settings.json directly into const vsCommand
variable (with some checks so a shell and a vsCommand cannot both be passed in)
pass vsCommand
into commands.executeCommand()
instead of the terminal.
Can you think of anything I'm missing?
Can you think of anything I'm missing?
Nope, looks good to me 👌🏾
Maybe merge this extension
https://marketplace.visualstudio.com/items?itemName=geddski.macros
into Action Buttons. It seems to complement Action Buttons nicely because it has exactly the features missing:
I have the save action button with:
"actionButtons": {
"defaultColor": "none",
"commands": [
{
"name": "$(save)",
"useVsCodeApi": true,
"command": "workbench.action.files.save"
},
]
},
@momiccioli, does it solve your problem?
Yes ! that works perfectly!
From: Mohammad Nabavi @.> Reply-To: seunlanlege/vscode-action-buttons @.> Date: Wednesday, June 21, 2023 at 11:15 AM To: seunlanlege/vscode-action-buttons @.> Cc: momiccioli @.>, Mention @.***> Subject: Re: [seunlanlege/vscode-action-buttons] Command Pallette Button (#37)
I have the save action button with:
"actionButtons": { "defaultColor": "none", "commands": [ { "name": "$(save)", "useVsCodeApi": true, "command": "workbench.action.files.save" }, ] }, @momiccioli, does it solve your problem?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Seun,
I use your buttons to run many scripts. For a few I of my scripts would like to run the save command automatically prior to the script running. is there a way to trigger this save when I run a script from another ActionButton?
I know about running items when I save a file but my needs are not that straight forward unfortunately.
Thought I would ask.
From: Michael Omiccioli @.> Date: Wednesday, June 21, 2023 at 11:43 AM To: seunlanlege/vscode-action-buttons @.>, seunlanlege/vscode-action-buttons @.> Cc: Mention @.> Subject: Re: [seunlanlege/vscode-action-buttons] Command Pallette Button (#37)
Yes ! that works perfectly!
From: Mohammad Nabavi @.> Reply-To: seunlanlege/vscode-action-buttons @.> Date: Wednesday, June 21, 2023 at 11:15 AM To: seunlanlege/vscode-action-buttons @.> Cc: momiccioli @.>, Mention @.***> Subject: Re: [seunlanlege/vscode-action-buttons] Command Pallette Button (#37)
I have the save action button with:
"actionButtons": { "defaultColor": "none", "commands": [ { "name": "$(save)", "useVsCodeApi": true, "command": "workbench.action.files.save" }, ] }, @momiccioli, does it solve your problem?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Whats the syntax to configure a button to run a command palette action? For example save current file.