debugger: Fix Go locator for subtests (#33694)

Closes #33054 

Release Notes:

- Fixed debugging Go subtests.
This commit is contained in:
Cole Miller 2025-07-01 07:34:50 -04:00 committed by GitHub
parent 0629804390
commit a5b2428897
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -117,7 +117,20 @@ impl DapLocator for GoLocator {
// HACK: tasks assume that they are run in a shell context,
// so the -run regex has escaped specials. Delve correctly
// handles escaping, so we undo that here.
if arg.starts_with("\\^") && arg.ends_with("\\$") {
if let Some((left, right)) = arg.split_once("/")
&& left.starts_with("\\^")
&& left.ends_with("\\$")
&& right.starts_with("\\^")
&& right.ends_with("\\$")
{
let mut left = left[1..left.len() - 2].to_string();
left.push('$');
let mut right = right[1..right.len() - 2].to_string();
right.push('$');
args.push(format!("{left}/{right}"));
} else if arg.starts_with("\\^") && arg.ends_with("\\$") {
let mut arg = arg[1..arg.len() - 2].to_string();
arg.push('$');
args.push(arg);