Fix environment not being inherited in debuggee.

This commit is contained in:
Martín Lucas Golini
2025-10-29 22:10:20 -03:00
parent 6ec1a10c47
commit f7a08b6f42

View File

@@ -1279,6 +1279,8 @@ void DebuggerPlugin::replaceKeysInJson(
return true;
};
std::vector<std::string> keysToRemove;
for ( auto& j : json ) {
if ( j.is_object() ) {
replaceKeysInJson( j, randomPort, solvedInputs );
@@ -1303,9 +1305,13 @@ void DebuggerPlugin::replaceKeysInJson(
j = std::move( argsArr );
continue;
} else if ( runConfig && val == KEY_ENV && buildConfig ) {
j = nlohmann::json::object();
for ( const auto& env : buildConfig->envs() )
j[env.first] = env.second;
if ( !buildConfig->envs().empty() ) {
j = nlohmann::json::object();
for ( const auto& env : buildConfig->envs() )
j[env.first] = env.second;
} else {
keysToRemove.push_back( "env" );
}
} else if ( val == KEY_STOPONENTRY ) {
j = false;
} else {
@@ -1329,6 +1335,10 @@ void DebuggerPlugin::replaceKeysInJson(
}
}
}
for ( const auto& key : keysToRemove ) {
json.erase( key );
}
}
std::unordered_map<std::string, DapConfigurationInput>