dap: fix runInTerminal with lldb-vscode

pull/1604/head
Blaž Hrastnik 3 years ago
parent 4e1b3b12f3
commit 7b1d682fe5

@ -479,10 +479,28 @@ impl Application {
Payload::Response(_) => unreachable!(), Payload::Response(_) => unreachable!(),
Payload::Request(request) => match request.command.as_str() { Payload::Request(request) => match request.command.as_str() {
RunInTerminal::COMMAND => { RunInTerminal::COMMAND => {
let arguments: dap::requests::RunInTerminalArguments = let mut arguments: dap::requests::RunInTerminalArguments =
serde_json::from_value(request.arguments.unwrap_or_default()).unwrap(); serde_json::from_value(request.arguments.unwrap_or_default()).unwrap();
// TODO: no unwrap // TODO: no unwrap
log::error!("run_in_terminal {:?}", arguments);
// HAXX: lldb-vscode uses $CWD/lldb-vscode which is wrong
let program = arguments.args[0]
.strip_prefix(
std::env::current_dir()
.expect("Couldn't get current working directory")
.as_path()
.to_str()
.unwrap(),
)
.and_then(|arg| arg.strip_prefix('/'))
.map(|arg| arg.to_owned())
.unwrap_or_else(|| arguments.args[0].clone());
arguments.args[0] = program;
log::error!("{}", arguments.args.join(" "));
// TODO: handle cwd // TODO: handle cwd
let process = std::process::Command::new("tmux") let process = std::process::Command::new("tmux")
.arg("split-window") .arg("split-window")

@ -392,13 +392,13 @@ fn debug_parameter_prompt(
Ok(call) Ok(call)
}); });
cx.jobs.callback(callback); cx.jobs.callback(callback);
} else if let Err(e) = dap_start_impl( } else if let Err(err) = dap_start_impl(
cx, cx,
Some(&config_name), Some(&config_name),
None, None,
Some(params.iter().map(|x| x.into()).collect()), Some(params.iter().map(|x| x.into()).collect()),
) { ) {
cx.editor.set_error(e.to_string()); cx.editor.set_error(err.to_string());
} }
}, },
) )

Loading…
Cancel
Save