@@ -1910,6 +1910,40 @@ mod cmd {
19101910 Ok(())
19111911 }
19121912
1913+ fn vsplit(
1914+ cx: &mut compositor::Context,
1915+ args: &[&str],
1916+ _event: PromptEvent,
1917+ ) -> anyhow::Result<()> {
1918+ let (_, doc) = current!(cx.editor);
1919+ let id = doc.id();
1920+
1921+ if let Some(path) = args.get(0) {
1922+ cx.editor.open(path.into(), Action::VerticalSplit)?;
1923+ } else {
1924+ cx.editor.switch(id, Action::VerticalSplit);
1925+ }
1926+
1927+ Ok(())
1928+ }
1929+
1930+ fn hsplit(
1931+ cx: &mut compositor::Context,
1932+ args: &[&str],
1933+ _event: PromptEvent,
1934+ ) -> anyhow::Result<()> {
1935+ let (_, doc) = current!(cx.editor);
1936+ let id = doc.id();
1937+
1938+ if let Some(path) = args.get(0) {
1939+ cx.editor.open(path.into(), Action::HorizontalSplit)?;
1940+ } else {
1941+ cx.editor.switch(id, Action::HorizontalSplit);
1942+ }
1943+
1944+ Ok(())
1945+ }
1946+
19131947 fn debug_eval(
19141948 cx: &mut compositor::Context,
19151949 args: &[&str],
@@ -1985,60 +2019,14 @@ mod cmd {
19852019 let breakpoints = breakpoints.clone();
19862020
19872021 let request = debugger.set_breakpoints(path, breakpoints);
1988− let _ = block_on(request).unwrap();
2022+ if let Err(e) = block_on(request) {
2023+ cx.editor
2024+ .set_error(format!("Failed to set breakpoints: {:?}", e));
2025+ }
19892026 }
19902027 }
19912028 }
19922029
1993− fn debug_breakpoint_condition(
1994− cx: &mut compositor::Context,
1995− args: &[&str],
1996− _event: PromptEvent,
1997− ) -> anyhow::Result<()> {
1998− let condition = args.join(" ");
1999− let condition = if condition.is_empty() {
2000− None
2001− } else {
2002− Some(condition)
2003− };
2004−
2005− edit_breakpoint_impl(cx, condition, None);
2006− Ok(())
2007− }
2008−
2009− fn vsplit(
2010− cx: &mut compositor::Context,
2011− args: &[&str],
2012− _event: PromptEvent,
2013− ) -> anyhow::Result<()> {
2014− let (_, doc) = current!(cx.editor);
2015− let id = doc.id();
2016−
2017− if let Some(path) = args.get(0) {
2018− cx.editor.open(path.into(), Action::VerticalSplit)?;
2019− } else {
2020− cx.editor.switch(id, Action::VerticalSplit);
2021− }
2022−
2023− Ok(())
2024− }
2025−
2026− fn hsplit(
2027− cx: &mut compositor::Context,
2028− args: &[&str],
2029− _event: PromptEvent,
2030− ) -> anyhow::Result<()> {
2031− let log_message = args.join(" ");
2032− let log_message = if log_message.is_empty() {
2033− None
2034− } else {
2035− Some(log_message)
2036− };
2037−
2038− edit_breakpoint_impl(cx, None, log_message);
2039− Ok(())
2040− }
2041−
20422030 fn debug_start(
20432031 cx: &mut compositor::Context,
20442032 args: &[&str],
@@ -2061,7 +2049,7 @@ mod cmd {
20612049 let mut args = args.to_owned();
20622050 let address = match args.len() {
20632051 0 => None,
2064− _ => Some(args.remove(0).parse().unwrap()),
2052+ _ => Some(args.remove(0).parse()?),
20652053 };
20662054 let name = match args.len() {
20672055 0 => None,
@@ -2072,20 +2060,35 @@ mod cmd {
20722060 Ok(())
20732061 }
20742062
2075− fn debug_set_logpoint(
2063+ fn debug_breakpoint_condition(
20762064 cx: &mut compositor::Context,
20772065 args: &[&str],
20782066 _event: PromptEvent,
20792067 ) -> anyhow::Result<()> {
2080− let (_, doc) = current!(cx.editor);
2081− let id = doc.id();
2068+ let condition = args.join(" ");
2069+ let condition = if condition.is_empty() {
2070+ None
2071+ } else {
2072+ Some(condition)
2073+ };
20822074
2083− if let Some(path) = args.get(0) {
2084− cx.editor.open(path.into(), Action::HorizontalSplit)?;
2075+ edit_breakpoint_impl(cx, condition, None);
2076+ Ok(())
2077+ }
2078+
2079+ fn debug_set_logpoint(
2080+ cx: &mut compositor::Context,
2081+ args: &[&str],
2082+ _event: PromptEvent,
2083+ ) -> anyhow::Result<()> {
2084+ let log_message = args.join(" ");
2085+ let log_message = if log_message.is_empty() {
2086+ None
20852087 } else {
2086− cx.editor.switch(id, Action::HorizontalSplit);
2087− }
2088+ Some(log_message)
2089+ };
20882090
2091+ edit_breakpoint_impl(cx, None, log_message);
20892092 Ok(())
20902093 }
20912094
@@ -4522,13 +4525,24 @@ fn dap_start_impl(
45224525 }
45234526 };
45244527
4525− let (mut debugger, events) = match socket {
4526− Some(socket) => block_on(Client::tcp(socket, 0)).unwrap(),
4527− None => block_on(Client::process(config.clone(), 0)).unwrap(),
4528+ let result = match socket {
4529+ Some(socket) => block_on(Client::tcp(socket, 0)),
4530+ None => block_on(Client::process(config.clone(), 0)),
4531+ };
4532+
4533+ let (mut debugger, events) = match result {
4534+ Ok(r) => r,
4535+ Err(e) => {
4536+ editor.set_error(format!("Failed to start debug session: {:?}", e));
4537+ return;
4538+ }
45284539 };
45294540
45304541 let request = debugger.initialize(config.name.clone());
4531− let _ = block_on(request).unwrap();
4542+ if let Err(e) = block_on(request) {
4543+ editor.set_error(format!("Failed to initialize debug adapter: {:?}", e));
4544+ return;
4545+ }
45324546
45334547 let start_config = match name {
45344548 Some(name) => config.templates.iter().find(|t| t.name == name),
@@ -4563,15 +4577,18 @@ fn dap_start_impl(
45634577
45644578 let args = to_value(args).unwrap();
45654579
4566− // TODO gracefully handle errors from debugger
4567− match &start_config.request[..] {
4568− "launch" => block_on(debugger.launch(args)).unwrap(),
4569− "attach" => block_on(debugger.attach(args)).unwrap(),
4580+ let result = match &start_config.request[..] {
4581+ "launch" => block_on(debugger.launch(args)),
4582+ "attach" => block_on(debugger.attach(args)),
45704583 _ => {
45714584 editor.set_error("Unsupported request".to_string());
45724585 return;
45734586 }
45744587 };
4588+ if let Err(e) = result {
4589+ editor.set_error(format!("Failed {} target: {:?}", start_config.request, e));
4590+ return;
4591+ }
45754592
45764593 // TODO: either await "initialized" or buffer commands until event is received
45774594 editor.debugger = Some(debugger);
@@ -4614,7 +4631,10 @@ fn dap_toggle_breakpoint(cx: &mut Context) {
46144631 let breakpoints = breakpoints.clone();
46154632
46164633 let request = debugger.set_breakpoints(path, breakpoints);
4617− let _ = block_on(request).unwrap();
4634+ if let Err(e) = block_on(request) {
4635+ cx.editor
4636+ .set_error(format!("Failed to set breakpoints: {:?}", e));
4637+ }
46184638 }
46194639}
46204640
@@ -4628,7 +4648,10 @@ fn dap_run(cx: &mut Context) {
46284648 return;
46294649 }
46304650 let request = debugger.configuration_done();
4631− let _ = block_on(request).unwrap();
4651+ if let Err(e) = block_on(request) {
4652+ cx.editor.set_error(format!("Failed to run: {:?}", e));
4653+ return;
4654+ }
46324655 debugger.is_running = true;
46334656 }
46344657}
@@ -4644,7 +4667,10 @@ fn dap_continue(cx: &mut Context) {
46444667 }
46454668
46464669 let request = debugger.continue_thread(debugger.stopped_thread.unwrap());
4647− let _ = block_on(request).unwrap();
4670+ if let Err(e) = block_on(request) {
4671+ cx.editor.set_error(format!("Failed to continue: {:?}", e));
4672+ return;
4673+ }
46484674 debugger.is_running = true;
46494675 debugger.stack_pointer = None;
46504676 }
@@ -4661,7 +4687,9 @@ fn dap_pause(cx: &mut Context) {
46614687
46624688 // FIXME: correct number here
46634689 let request = debugger.pause(0);
4664− let _ = block_on(request).unwrap();
4690+ if let Err(e) = block_on(request) {
4691+ cx.editor.set_error(format!("Failed to pause: {:?}", e));
4692+ }
46654693 }
46664694}
46674695
@@ -4676,7 +4704,9 @@ fn dap_in(cx: &mut Context) {
46764704 }
46774705
46784706 let request = debugger.step_in(debugger.stopped_thread.unwrap());
4679− let _ = block_on(request).unwrap();
4707+ if let Err(e) = block_on(request) {
4708+ cx.editor.set_error(format!("Failed to step: {:?}", e));
4709+ }
46804710 }
46814711}
46824712
@@ -4691,7 +4721,9 @@ fn dap_out(cx: &mut Context) {
46914721 }
46924722
46934723 let request = debugger.step_out(debugger.stopped_thread.unwrap());
4694− let _ = block_on(request).unwrap();
4724+ if let Err(e) = block_on(request) {
4725+ cx.editor.set_error(format!("Failed to step: {:?}", e));
4726+ }
46954727 }
46964728}
46974729
@@ -4706,7 +4738,9 @@ fn dap_next(cx: &mut Context) {
47064738 }
47074739
47084740 let request = debugger.next(debugger.stopped_thread.unwrap());
4709− let _ = block_on(request).unwrap();
4741+ if let Err(e) = block_on(request) {
4742+ cx.editor.set_error(format!("Failed to step: {:?}", e));
4743+ }
47104744 }
47114745}
47124746
@@ -4726,7 +4760,14 @@ fn dap_variables(cx: &mut Context) {
47264760 }
47274761
47284762 let frame_id = debugger.stack_pointer.clone().unwrap().id;
4729− let scopes = block_on(debugger.scopes(frame_id)).unwrap();
4763+ let scopes = match block_on(debugger.scopes(frame_id)) {
4764+ Ok(s) => s,
4765+ Err(e) => {
4766+ cx.editor
4767+ .set_error(format!("Failed to get scopes: {:?}", e));
4768+ return;
4769+ }
4770+ };
47304771 let mut s = String::new();
47314772
47324773 for scope in scopes.iter() {
@@ -4752,7 +4793,11 @@ fn dap_terminate(cx: &mut Context) {
47524793
47534794 if let Some(debugger) = &mut cx.editor.debugger {
47544795 let request = debugger.disconnect();
4755− let _ = block_on(request).unwrap();
4796+ if let Err(e) = block_on(request) {
4797+ cx.editor
4798+ .set_error(format!("Failed to disconnect: {:?}", e));
4799+ return;
4800+ }
47564801 cx.editor.debugger = None;
47574802 }
47584803}