-4

I found these three commands in Visual Studio Code:

  • Developer: Restart Extension Host
  • Developer: Debug Extension Host In Dev Tools
  • Developer: Debug Extension Host In New Window

From their names, it seems like they might be useful for my purpose. However, I couldn’t find any official documentation that explains what each of these commands actually do.

Can someone please explain the purpose of these commands, and how I can use them while developing extensions.

12
  • 2
    "From their names, it seems like they might be useful for my purpose" - You haven't told us what your purposes are... Commented Nov 21 at 16:28
  • I am trying to start developing extensions. I think it might help in the process. Commented Nov 21 at 16:32
  • Is there no documentation on debugging extensions? Two of these do the same thing Commented Nov 21 at 16:33
  • @OneCricketeer there is documentation on debugging extensions. But in those documentations, i could not find how to use these three commands. Commented Nov 21 at 16:36
  • 5
    Not everything is documented. You need to go back to the code base itself, github.com/microsoft/vscode Commented Nov 21 at 18:01

1 Answer 1

3

As I said in the comments, I cannot really cover the entire topic, and we agree to shorten it. And even in this case... I'm not sure what part you already know, so I have to start with first principles. This Extension Host technology is relatively complicated, but it makes VSCode extension development pretty convenient. The key is to run two different VSCode instances. I'll call them Instance A and Instance B.

Instance A

Let's say you have already functional extension code. You can debug it using a specially set up launch.json, something like this:

{
   "version": "0.2.0",
    "configurations": [
        {
            "args": [
                "--extensionDevelopmentPath=${workspaceFolder}"
            ],
            "name": "Launch Extension",
            "request": "launch",
            "type": "extensionHost"
        },
    ]
}

Now when you hit F5, another VSCode instance is started, let's call it Instance B.

Instance B — Extension Host

This instance is called Extension Host. Is it unusual in the following way: your extension under the development is loaded on a temporary basis and only for this VSCode instance. If your extension is already installed, the installed code will be ignored, the effective extension version is the one you are debugging. You will see the string [Extension Development Host]... in your search line.

Generally, this instance does not have to do anything related to programming. Its workspace has to use some features addressed by the extension, so you could test the behavior.

Restart Command

Developer: Restart Extension Host

You can invoke this command in Instance B, in contrast to restarting the debugging session you can restart in Instance A with Ctrl+Shift+F5.

This command is a more lightweight action, it is faster, does not break the debugger attachment, and it can preserve some of the Instance B states, and so on. Roughly speaking, it internally skips some relatively long initialization of the debugging session. You could have noticed that this initialization can take some time, depending on the product you debug.

Two Debug Commands: Developer: Debug Extension Host in...

These two commands are more advanced and not even related to F5 launch of your extension code:

Developer: Debug Extension Host In Dev Tools
Developer: Debug Extension Host In New Window

Generally, these two tools are way more advanced and not used often. They can be useful when your extension is already developed, published, and installed globally in your system. By running an Extension Host using these tools, you just analyze its behavior to find the sources of bugs, glitches, and the like.

In Dev Tools...

The command starts Electron Dev Tools (VSCode is implemented as an Electron application), which is functionally the same thing as the Chromium Dev Tools. The window similar to the Chromium Dev Tools window is opened in a VSCode instance.

This is too big topic. You can inspect objects, track the network activity, and a lot more.

In New Window...

This is a new dedicated window that looks exactly like any other VSCode window. It serves as a pure debugging interface via the RUN AND DEBUG section of the Explorer. You will see the call stack, watches, breakpoins and so on, immediately after starting the debugging session. It is used for in-depth debugging of an existing extension.

References

VSCode API used in extension development

VSCode Extension API

General information on using Extension Host and its configuration:
https://code.visualstudio.com/api/advanced-topics/extension-host

These references are incomplete. Unfortunately, the extension development information is not concentrated but is disperced in different sources...

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you very much for your time and effort.
You are very welcome, Ahmad, If you have issues related to the development of those extensions, you know who you can ask. :-)
I've just added references, also not comprehensive.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.