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

Time:12-02

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.

CodePudding user response:

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.

  • Related