on master help sign in
dap: Remove some unwraps
commit573cb399261f9ab8f799dcf82a40220dcc6539e4 authorBlaž Hrastnik <blaz@mxxn.io> dateThu 2 Dec 2021, 10:20 (5 years ago) parentffc89e4
2 files changed+18−15
helix-term/src/application.rs+14−12 helix-term/src/commands/dap.rs+4−3
helix-term/src/application.rs+14−12
@@ -388,18 +388,20 @@ impl Application {
388388 }
389389 Event::Breakpoint(events::Breakpoint { reason, breakpoint }) => match &reason[..] {
390390 "new" => {
391− self.editor
392− .breakpoints
393− .entry(breakpoint.source.unwrap().path.unwrap()) // TODO: no unwraps
394− .or_default()
395− .push(Breakpoint {
396− id: breakpoint.id,
397− verified: breakpoint.verified,
398− message: breakpoint.message,
399− line: breakpoint.line.unwrap().saturating_sub(1), // TODO: no unwrap
400− column: breakpoint.column,
401− ..Default::default()
402− });
391+ if let Some(source) = breakpoint.source {
392+ self.editor
393+ .breakpoints
394+ .entry(source.path.unwrap()) // TODO: no unwraps
395+ .or_default()
396+ .push(Breakpoint {
397+ id: breakpoint.id,
398+ verified: breakpoint.verified,
399+ message: breakpoint.message,
400+ line: breakpoint.line.unwrap().saturating_sub(1), // TODO: no unwrap
401+ column: breakpoint.column,
402+ ..Default::default()
403+ });
404+ }
403405 }
404406 "changed" => {
405407 for breakpoints in self.editor.breakpoints.values_mut() {
helix-term/src/commands/dap.rs+4−3
@@ -78,9 +78,10 @@ pub fn jump_to_stack_frame(editor: &mut Editor, frame: &helix_dap::StackFrame) {
7878 return;
7979 };
8080
81− editor
82− .open(path, helix_view::editor::Action::Replace)
83− .unwrap(); // TODO: there should be no unwrapping!
81+ if let Err(e) = editor.open(path, helix_view::editor::Action::Replace) {
82+ editor.set_error(format!("Unable to jump to stack frame: {}", e));
83+ return;
84+ }
8485
8586 let (view, doc) = current!(editor);
8687