microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.96k stars 29.53k forks source link

Workspace trust - Extension Development Host #124182

Open lszomoru opened 3 years ago

lszomoru commented 3 years ago

Issue copied from https://github.com/microsoft/vscode/issues/120251#issuecomment-842797717

Maybe I'm missing/mixing something, but it seems the debugging process of an extension, while opening trusted/untrusted workspaces as the Extension Development Host, does not respect if the extension supports untrusted workspace or not, at least in some scenarios.

My extension does not have the untrustedWorkspaces capability entry yet, then I do a simple debug:

  1. Start debugging
  2. Open some random folder as Extension Development Host
  3. Choose Untrusted
  4. The extension is active, which is weird because I didn't added support yet

Then, I close the Extension Development Host, add the untrustedWorkspaces capability entry and rebuild the extension. But now...

  1. Start debugging
  2. Open some random folder as Extension Development Host
  3. Choose Untrusted
  4. The extension is active, which is correct
  5. Then I open another random folder, using File / Open command
  6. And now I choose Trusted to this folder
  7. The extension is not active 😕

But, if I close the Extension Development Host window and restart the debugging process, the extension now properly activates. In fact, all installed extensions does activate.

I don't thing the error is just the debugging itself, but the trust engine seems to be failing when you switch/activates new folders while debugging. I have noticed a similar extension activation issue while playing with trusting/untrusting workspaces. It seems the extensions are not properly activated/deactivated when you do this.

Is it an issue with the debugging process? I mean, is it expected that I could play with untrusted workspaces while debugging, or is not a supported scenario yet, and I must package my extension and install the .vsix file, to test the extension?

Thank you

karrtikr commented 3 years ago

@lszomoru I was trying to add limited support for untrusted workspaces in the Python extension which is when I encountered this. Python extension in the Extension Development host activates regardless of whether untrusted workspaces is supported for package.json or not. Is this expected right now?