1

I press F5 to debug a VSCode extension and VSCode will open a new window that will contain the extension. The extension will open a new VSCode window to open a specific project. But this new VSCode window didn't contain the extension and I can't debug it anymore. What can I do?

Mark
  • 143,421
  • 24
  • 428
  • 436
Pandy
  • 138
  • 1
  • 4
  • Not sure I fully understand, but you can indicate in your `Run Extension` launch configuration which folder/project to open, so you could tell it to open the specific project you want immediately and it will be in the Extension Host for debugging. Is that what you want to do? – Mark Aug 26 '22 at 07:56
  • if you open a folder in the first launched Extentionhost it will remember this folder the next time you want to debug the extension with F5 – rioV8 Aug 26 '22 at 09:13

2 Answers2

1

Your automatically generated extension launch configuration should look like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Run Extension",
            "type": "extensionHost",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": [

                "${workspaceFolder}/../OneDrive/Test Bed",     // add the path here 

                "--extensionDevelopmentPath=${workspaceFolder}"
            ]
        },
        {
            "name": "Extension Tests",
            "type": "extensionHost",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": [
                "--extensionDevelopmentPath=${workspaceFolder}",
                "--extensionTestsPath=${workspaceFolder}/test/suite/index"
            ]
        }
    ]
}

You see in the Run Extension configuration that I added a path from the extension's ${workspaceFolder} up one level and then into my OneDrive folder to another folder named Test Bed. That Test Bed folder will be opened in the first ExtensionHost window that is opened when you F5 and you can debug the extension using that folder immediately.

Mark
  • 143,421
  • 24
  • 428
  • 436
0

Not sure if you are looking for a specific extension. If you have already installed the debugger extension, Try to uninstall/reinstall.

  • https://vscode-docs.readthedocs.io/en/stable/extensions/debugging-extensions/#:~:text=You%20can%20easily%20run%20your,view%20or%20the%20Debug%20Console%20. – Fawad Ali Siddiqi Aug 26 '22 at 07:51