Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.

Conversation

@xhulz
Copy link
Contributor

@xhulz xhulz commented Sep 28, 2022

PR description

ref: #203

Running truffle debug with appropriate flag (--vscode) triggers debugger to launch / run in VS Code

The command line to execute the vscode debugger:

open 'vscode://trufflesuite-csi.truffle-vscode/debug?{"txHash":"0x97a81dbca1ea95263bb75b0147c99f263fe21cf702abe8974c310c9fa834d9b9","workingDirectory":"/Users/xhulz/Documents/xpto","providerUrl":"http://127.0.0.1:8545"}'

This command line is basically formed by: open 'app://extension_id/command_name?args'.

Important: If the Truffle vscode extension is not installed, vscode will ask if the user wants to install it. So, there is no reason to validate it earlier.

Breaking the command line:

  • App: vscode
  • Extension ID: trufflesuite-csi.truffle-vscode
  • Command name: debug
  • Args: {txHash: string, workingDirectory: string, providerUrl: string}

Example: {"txHash":"0x97a81dbca1ea95263bb75b0147c99f263fe21cf702abe8974c310c9fa834d9b9","workingDirectory":"/Users/xhulz/Documents/xpto","providerUrl":"http://127.0.0.1:8545"}

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if documentation updates are required.

@xhulz xhulz changed the title Feat/launch debug from terminal Feat: Running truffle debug with appropriate flag (--vscode) triggers debugger to launch / run in VS Code Sep 28, 2022
@xhulz xhulz added the enhancement New feature or request label Sep 28, 2022
@kevinbluer
Copy link
Contributor

cc @gnidan for 👀

@gnidan
Copy link

gnidan commented Sep 28, 2022

Whoa! How does this work? You can tell VS Code to intercept a command given to the in-IDE shell? So VS Code will observe that you typed truffle debug --vscode and it'll override the default behavior and do its own thing?

Copy link
Contributor

@michaeljohnbennett michaeljohnbennett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@xhulz
Copy link
Contributor Author

xhulz commented Sep 29, 2022

Hey @gnidan,

The vscode has a URI controller class like the apps have on mobile. It's a listener that listen to this protocol: vscode://. For example, if you put this line on web browser vscode://trufflesuite-csi.truffle-vscode/debug?{"txHash":"0x97a81dbca1ea95263bb75b0147c99f263fe21cf702abe8974c310c9fa834d9b9","workingDirectory":"/Users/xhulz/Documents/xpto","providerUrl":"http://127.0.0.1:8545"} it will call the vscode. I'd like to send you more information about that class, but unfortunately, vscode does not have a good documentation, so every time we need to dig on the vscode repo to discover this things...

In the Truffle case, we will have to receive (on Truffle CLI) the command truffle debug --vscode and execute an internal CLI command calling open 'vscode://trufflesuite-csi.truffle-vscode/debug?{"txHash":"0x97a81dbca1ea95263bb75b0147c99f263fe21cf702abe8974c310c9fa834d9b9","workingDirectory":"/Users/xhulz/Documents/xpto","providerUrl":"http://127.0.0.1:8545"}' or even doing some like window.open('vscode://trufflesuite-csi.truffle-vscode/debug?{"txHash":"0x97a81dbca1ea95263bb75b0147c99f263fe21cf702abe8974c310c9fa834d9b9","workingDirectory":"/Users/xhulz/Documents/xpto","providerUrl":"http://127.0.0.1:8545"}').

If i can help, just let me know :)

Cheers!

Copy link
Contributor

@acuarica acuarica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@xhulz
Copy link
Contributor Author

xhulz commented Sep 30, 2022

Ok @acuarica,

Your suggestions have been implemented

Thank you

@gnidan
Copy link

gnidan commented Sep 30, 2022

Oh, just to clarify: ideally we can interface with the extension from any terminal. I was just asking the question in case that's not easy.

@xhulz xhulz marked this pull request as ready for review November 3, 2022 12:12
@xhulz xhulz merged commit 83e82a8 into develop Nov 4, 2022
@xhulz xhulz deleted the feat/launch-debug-from-terminal branch November 4, 2022 08:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants