debugger: Prevent port collision when attaching to existing node debugger (#32862)
We were translating port configuration incorrectly, using it for both attach target and debugger port. This however meant that we were spawning a 2nd process that'd listen on the same port as the existing debugger. Closes #32836 Release Notes: - debugger: Fixed issues with auto-translated Visual Studio Code debug configs for attaching to existing node debugger instances.
This commit is contained in:
parent
336c49b10d
commit
a69ebf038a
2 changed files with 7 additions and 8 deletions
|
@ -96,6 +96,9 @@ impl JsDebugAdapter {
|
||||||
.or_insert(delegate.worktree_root_path().to_string_lossy().into());
|
.or_insert(delegate.worktree_root_path().to_string_lossy().into());
|
||||||
|
|
||||||
configuration.entry("type").and_modify(normalize_task_type);
|
configuration.entry("type").and_modify(normalize_task_type);
|
||||||
|
configuration
|
||||||
|
.entry("console")
|
||||||
|
.or_insert("externalTerminal".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(DebugAdapterBinary {
|
Ok(DebugAdapterBinary {
|
||||||
|
|
|
@ -26,14 +26,14 @@ struct VsCodeDebugTaskDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VsCodeDebugTaskDefinition {
|
impl VsCodeDebugTaskDefinition {
|
||||||
fn try_to_zed(self, replacer: &EnvVariableReplacer) -> anyhow::Result<DebugScenario> {
|
fn try_to_zed(mut self, replacer: &EnvVariableReplacer) -> anyhow::Result<DebugScenario> {
|
||||||
let label = replacer.replace(&self.name);
|
let label = replacer.replace(&self.name);
|
||||||
let mut config = replacer.replace_value(self.other_attributes);
|
let mut config = replacer.replace_value(self.other_attributes);
|
||||||
let adapter = task_type_to_adapter_name(&self.r#type);
|
let adapter = task_type_to_adapter_name(&self.r#type);
|
||||||
if let Some(config) = config.as_object_mut() {
|
if let Some(config) = config.as_object_mut() {
|
||||||
if adapter == "JavaScript" {
|
if adapter == "JavaScript" {
|
||||||
config.insert("type".to_owned(), self.r#type.clone().into());
|
config.insert("type".to_owned(), self.r#type.clone().into());
|
||||||
if let Some(port) = self.port {
|
if let Some(port) = self.port.take() {
|
||||||
config.insert("port".to_owned(), port.into());
|
config.insert("port".to_owned(), port.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ fn task_type_to_adapter_name(task_type: &str) -> String {
|
||||||
mod tests {
|
mod tests {
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use crate::{DebugScenario, DebugTaskFile, TcpArgumentsTemplate};
|
use crate::{DebugScenario, DebugTaskFile};
|
||||||
|
|
||||||
use super::VsCodeDebugTaskFile;
|
use super::VsCodeDebugTaskFile;
|
||||||
|
|
||||||
|
@ -154,11 +154,7 @@ mod tests {
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"port": 17,
|
"port": 17,
|
||||||
}),
|
}),
|
||||||
tcp_connection: Some(TcpArgumentsTemplate {
|
tcp_connection: None,
|
||||||
port: Some(17),
|
|
||||||
host: None,
|
|
||||||
timeout: None,
|
|
||||||
}),
|
|
||||||
build: None
|
build: None
|
||||||
}])
|
}])
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue