Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: new command to run multiple commands - runCommands #177722

Closed
2 tasks done
ulugbekna opened this issue Mar 20, 2023 · 0 comments
Closed
2 tasks done

Test: new command to run multiple commands - runCommands #177722

ulugbekna opened this issue Mar 20, 2023 · 0 comments

Comments

@ulugbekna
Copy link
Contributor

ulugbekna commented Mar 20, 2023

Refs: #871

Complexity: 3

Create Issue


Summary

We added a new command (with command ID runCommands) that allows running multiple commands, passed to runCommands as argument. It allows creating a single keybinding that can run multiple commands when triggered.

runCommands takes a single argument of this shape:

type arg = {
	commands: (string | { command: string; args: any[])[];
};

Testing

Part 1

Let's add a keybinding that uses this command and make sure things run as expected:

  1. Open your keybindings.json (you can invoke command "Open Keyboard Shortcuts (JSON)" from command palette)
  2. Create a new keybinding that uses runCommands within keybindings.json, e.g., your keybindings.json contents could look like this - we have two keybindings:
[
	{ // hide or show all help-bars
		"key": "ctrl+h",
		"command": "runCommands", 
		"args": {
			"commands": [
				"workbench.action.toggleSidebarVisibility",
				"workbench.action.toggleActivityBarVisibility",
				"workbench.action.toggleAuxiliaryBar"
			]
		}
	},
	{ // create a new file and insert the msft header 
		"key": "ctrl+n",
		"command": "runCommands",
		"args": {
			"commands": [
				{ 
					"command": "workbench.action.files.newUntitledFile",
					"args": {
						"languageId": "typescript",
					}
				},
				{
					"command": "type",
					"args": {
						"text": "/*---------------------------------------------------------------------------------------------\n *  Copyright (c) Microsoft Corporation. All rights reserved.\n *  Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/"
					}
				},
			]
		}
	}
]
  1. Make sure these keybindings work as expected (don't mind indentation issues with the second command if there're any)

Part 2

When you're editing command IDs (for field command) and arguments (args field) make sure you get code completion for command names & argument fields - both when writing the keybinding object and when writing an object to pass to runCommands.


That's it, thank you very much for testing!


I invite you to get creative with the new runCommands :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants