mariniou77
mariniou77

Reputation: 37

How to get the focus (cursor) from the editor to the panel(terminal) visual studio code extension

I am writing a visual studio code extension and at some point, when I call a command to open and run a script at the terminal, I want simultaneously the terminal to take the focus (cursor) from everywhere else.

Thank you in advance.

Upvotes: 0

Views: 547

Answers (1)

Kamen Minkov
Kamen Minkov

Reputation: 3712

It is as simple as this:

vscode.commands.executeCommand("workbench.action.terminal.focus");

You're basically invoking a command with the same identifier you'd use if you were to assign it to a keyboard shortcut - and you can look up other commands in the editor itself if you invoke workbench.action.openGlobalKeybindings.

Documented here.

Upvotes: 1

Related Questions