microsoft / vscode

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

import vscode with `DebugSession` will exit unexpectly #113533

Closed Abbyyan closed 3 years ago

Abbyyan commented 3 years ago

I'm using the DebugSession to create a debug extension. When there are some info returned from my debugger, i wan't to show the user about the info msg. I'm try to use vscode.window.showInformationMessage to achieve this, but when i using vscode.window.showInformationMessage in a class extends from DebugSession, the debugger extension will exit unexpectedly. Is there anything wrong of my usage please. Hope for your help. Thanks a lot.

Abbyyan commented 3 years ago
  1. Find from https://github.com/microsoft/vscode-debugadapter-node/blob/fe3dbb9a9b5526b8c2d8aff1986321a2bb2f465d/adapter/src/debugSession.ts#L864, there is a customRequest. Does this means i can send a custom request from Debug Adapter to vsocde(client)? If so, how i can handle how to deal with the request on the client side please? Thanks a lot.
  2. Or could i send some event to vscode which can show Info in the vscode UI ? https://github.com/microsoft/vscode-debugadapter-node/blob/fe3dbb9a9b5526b8c2d8aff1986321a2bb2f465d/adapter/src/protocol.ts#L150
weinand commented 3 years ago

Normally a debug adapter runs as a separate process outside of VS Code's extension host process, and has no access to VS Code's extension API (e.g. vscode.window.showInformationMessage).

But if your debug adapter is implemented in JavaScript/Typescript then you can run it inside the extension host process and then it does have access to all extension APIs.

Please see https://github.com/microsoft/vscode-mock-debug/blob/85f04c5ae88a592098ce64008872500026d2a691/src/extension.ts#L26-L45: The "runModes" 'server' | 'namedPipeServer' | 'inline' all run the DA inside the extension host. Only 'external' runs the DA externally.