on master help sign in
dap: fix runInTerminal with lldb-vscode
commit7b1d682fe55cfa72c1ecf5a1763940cf105902e4 authorBlaž Hrastnik <blaz@mxxn.io> dateThu 17 Feb 2022, 12:22 (5 years ago) parent4e1b3b1
2 files changed+21−3
helix-term/src/application.rs+19−1 helix-term/src/commands/dap.rs+2−2
helix-term/src/application.rs+19−1
@@ -479,10 +479,28 @@ impl Application {
479479 Payload::Response(_) => unreachable!(),
480480 Payload::Request(request) => match request.command.as_str() {
481481 RunInTerminal::COMMAND => {
482− let arguments: dap::requests::RunInTerminalArguments =
482+ let mut arguments: dap::requests::RunInTerminalArguments =
483483 serde_json::from_value(request.arguments.unwrap_or_default()).unwrap();
484484 // TODO: no unwrap
485485
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+
486504 // TODO: handle cwd
487505 let process = std::process::Command::new("tmux")
488506 .arg("split-window")
helix-term/src/commands/dap.rs+2−2
@@ -392,13 +392,13 @@ fn debug_parameter_prompt(
392392 Ok(call)
393393 });
394394 cx.jobs.callback(callback);
395− } else if let Err(e) = dap_start_impl(
395+ } else if let Err(err) = dap_start_impl(
396396 cx,
397397 Some(&config_name),
398398 None,
399399 Some(params.iter().map(|x| x.into()).collect()),
400400 ) {
401− cx.editor.set_error(e.to_string());
401+ cx.editor.set_error(err.to_string());
402402 }
403403 },
404404 )