on master help sign in
Support remote debug adapter
commit4ee66b876613c3d2c06945520e0c5e392d9315d1 authorDmitry Sharshakov <d3dx12.xx@gmail.com> dateWed 25 Aug 2021, 19:14 (5 years ago) parentba96f5d
1 file changed+36−4
helix-term/src/commands.rs+36−4
helix-term/src/commands.rs+36−4
@@ -2032,7 +2032,25 @@ mod cmd {
20322032 0 => None,
20332033 _ => Some(args.remove(0)),
20342034 };
2035− dap_start_impl(&mut cx.editor, name, Some(args));
2035+ dap_start_impl(&mut cx.editor, name, None, Some(args));
2036+ Ok(())
2037+ }
2038+
2039+ fn debug_remote(
2040+ cx: &mut compositor::Context,
2041+ args: &[&str],
2042+ _event: PromptEvent,
2043+ ) -> anyhow::Result<()> {
2044+ let mut args = args.to_owned();
2045+ let address = match args.len() {
2046+ 0 => None,
2047+ _ => Some(args.remove(0).parse().unwrap()),
2048+ };
2049+ let name = match args.len() {
2050+ 0 => None,
2051+ _ => Some(args.remove(0)),
2052+ };
2053+ dap_start_impl(&mut cx.editor, name, address, Some(args));
20362054 Ok(())
20372055 }
20382056
@@ -2282,6 +2300,13 @@ mod cmd {
22822300 fun: debug_start,
22832301 completer: Some(completers::filename),
22842302 },
2303+ TypableCommand {
2304+ name: "debug-remote",
2305+ alias: Some("dbg-tcp"),
2306+ doc: "Connect to a debug adapter by TCP address and start a debugging session from a given template with given parameters.",
2307+ fun: debug_remote,
2308+ completer: Some(completers::filename),
2309+ },
22852310 TypableCommand {
22862311 name: "debug-eval",
22872312 alias: None,
@@ -4406,7 +4431,12 @@ fn suspend(_cx: &mut Context) {
44064431}
44074432
44084433// DAP
4409−fn dap_start_impl(editor: &mut Editor, name: Option<&str>, params: Option<Vec<&str>>) {
4434+fn dap_start_impl(
4435+ editor: &mut Editor,
4436+ name: Option<&str>,
4437+ socket: Option<std::net::SocketAddr>,
4438+ params: Option<Vec<&str>>,
4439+) {
44104440 use helix_dap::Client;
44114441 use helix_lsp::block_on;
44124442 use serde_json::to_value;
@@ -4435,8 +4465,10 @@ fn dap_start_impl(editor: &mut Editor, name: Option<&str>, params: Option<Vec<&s
44354465 }
44364466 };
44374467
4438− let started = Client::process(config.clone(), 0);
4439− let (mut debugger, events) = block_on(started).unwrap();
4468+ let (mut debugger, events) = match socket {
4469+ Some(socket) => block_on(Client::tcp(socket, 0)).unwrap(),
4470+ None => block_on(Client::process(config.clone(), 0)).unwrap(),
4471+ };
44404472
44414473 let request = debugger.initialize(config.name.clone());
44424474 let _ = block_on(request).unwrap();