on master help sign in
dap: fix runInTerminal with lldb-vscode
7b1d682Blaž Hrastnik
helix-term/src/application.rs+19−1
@@ -479,10 +479,28 @@ impl Application {
479 Payload::Response(_) => unreachable!(),
479 Payload::Response(_) => unreachable!(),
480 Payload::Request(request) => match request.command.as_str() {
480 Payload::Request(request) => match request.command.as_str() {
481 RunInTerminal::COMMAND => {
481 RunInTerminal::COMMAND => {
482− let arguments: dap::requests::RunInTerminalArguments =
482+ let mut arguments: dap::requests::RunInTerminalArguments =
483 serde_json::from_value(request.arguments.unwrap_or_default()).unwrap();
483 serde_json::from_value(request.arguments.unwrap_or_default()).unwrap();
484 // TODO: no unwrap
484 // TODO: no unwrap
485
485
486+ log::error!("run_in_terminal {:?}", arguments);
487+
488+ // HAXX: lldb-vscode uses $CWD/lldb-vscode which is wrong
489+ let program = arguments.args[0]
490+ .strip_prefix(
491+ std::env::current_dir()
492+ .expect("Couldn't get current working directory")
493+ .as_path()
494+ .to_str()
495+ .unwrap(),
496+ )
497+ .and_then(|arg| arg.strip_prefix('/'))
498+ .map(|arg| arg.to_owned())
499+ .unwrap_or_else(|| arguments.args[0].clone());
500+ arguments.args[0] = program;
501+
502+ log::error!("{}", arguments.args.join(" "));
503+
486 // TODO: handle cwd
504 // TODO: handle cwd
487 let process = std::process::Command::new("tmux")
505 let process = std::process::Command::new("tmux")
488 .arg("split-window")
506 .arg("split-window")
helix-term/src/commands/dap.rs+2−2
@@ -392,13 +392,13 @@ fn debug_parameter_prompt(
392 Ok(call)
392 Ok(call)
393 });
393 });
394 cx.jobs.callback(callback);
394 cx.jobs.callback(callback);
395− } else if let Err(e) = dap_start_impl(
395+ } else if let Err(err) = dap_start_impl(
396 cx,
396 cx,
397 Some(&config_name),
397 Some(&config_name),
398 None,
398 None,
399 Some(params.iter().map(|x| x.into()).collect()),
399 Some(params.iter().map(|x| x.into()).collect()),
400 ) {
400 ) {
401− cx.editor.set_error(e.to_string());
401+ cx.editor.set_error(err.to_string());
402 }
402 }
403 },
403 },
404 )
404 )