Skip to content

onDidExecuteCommand listener running twice for single command #78274

@alexr00

Description

@alexr00

This is the only way I've been able to repro this issue. I started with the hello world extension sample and modified the the activate:

export function activate(context: vscode.ExtensionContext) {
	// Use the console to output diagnostic information (console.log) and errors (console.error)
	// This line of code will only be executed once when your extension is activated
	console.log('Congratulations, your extension "helloworld-sample" is now active!');

	// The command has been defined in the package.json file
	// Now provide the implementation of the command with registerCommand
	// The commandId parameter must match the command field in package.json
	const disposables: vscode.Disposable[] = [];
	disposables.push(vscode.commands.registerCommand('extension.helloWorld', () => {
		// The code you place here will be executed every time your command is executed

		// Display a message box to the user
		vscode.window.showInformationMessage('Hello World!');
	}));

	disposables.push(vscode.commands.onDidExecuteCommand((e: vscode.CommandExecutionEvent) => {
		console.log(e.command);
	}));

	context.subscriptions.push(...disposables);
}

The command isn't actually running twice, but the listener for onDidExecuteCommand does get called twice.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions