Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

launch.json "mode": "auto" #1780

Closed
gertcuykens opened this issue Jul 9, 2018 · 5 comments
Closed

launch.json "mode": "auto" #1780

gertcuykens opened this issue Jul 9, 2018 · 5 comments

Comments

@gertcuykens
Copy link
Contributor

gertcuykens commented Jul 9, 2018

auto mode please that switches between "test" and "debug" depending the selected file is *_test.go

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "auto", <= dynamically adjust between debug and test depending on selected file *_test.go
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${fileDirname}",
            "env": {},
            "args": [],
            "showLog": true
        }
    ]
}
@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jul 10, 2018

That would be cool. But instead of introducing a new mode, how about updating the current debug mode to be smart enough to use test when debugging a test file?

PRs are welcome. The change should be pretty simple.

Code pointers:

@gertcuykens
Copy link
Contributor Author

How do you get current selected file path in vscode?

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jul 16, 2018

vscode.window.activeTextEditor.document.fileName

prism4time added a commit to prism4time/vscode-go that referenced this issue Aug 9, 2018
use regex to check if the current file is for test
prism4time added a commit to prism4time/vscode-go that referenced this issue Aug 9, 2018
prism4time added a commit to prism4time/vscode-go that referenced this issue Aug 10, 2018
ramya-rao-a pushed a commit that referenced this issue Aug 10, 2018
* Add auto `test` debug mode for launch.json(#1780)

check filename to get debug mode

* Remove redundant `else` and add check for null activeEditor
@ramya-rao-a
Copy link
Contributor

@gertcuykens @qzyse2017 on second thoughts, having a separate mode called auto is better. This way we wont be breaking the expectation of users who might have been just looking at their test code but then want to debug the actual package.

@qzyse2017 See 2cc9952

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Aug 13, 2018

The auto mode is now available in the latest update (0.6.86) to the Go extension.

Thanks for logging this @gertcuykens and thanks to @qzyse2017 for the PR!

@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants