on master help sign in
dap: Remove some unwraps
573cb39Blaž Hrastnik
helix-term/src/application.rs+14−12
@@ -388,18 +388,20 @@ impl Application {
388 }
388 }
389 Event::Breakpoint(events::Breakpoint { reason, breakpoint }) => match &reason[..] {
389 Event::Breakpoint(events::Breakpoint { reason, breakpoint }) => match &reason[..] {
390 "new" => {
390 "new" => {
391+ if let Some(source) = breakpoint.source {
391− self.editor
392+ self.editor
392− .breakpoints
393+ .breakpoints
393− .entry(breakpoint.source.unwrap().path.unwrap()) // TODO: no unwraps
394+ .entry(source.path.unwrap()) // TODO: no unwraps
394− .or_default()
395+ .or_default()
395− .push(Breakpoint {
396+ .push(Breakpoint {
396− id: breakpoint.id,
397+ id: breakpoint.id,
397− verified: breakpoint.verified,
398+ verified: breakpoint.verified,
398− message: breakpoint.message,
399+ message: breakpoint.message,
399− line: breakpoint.line.unwrap().saturating_sub(1), // TODO: no unwrap
400+ line: breakpoint.line.unwrap().saturating_sub(1), // TODO: no unwrap
400− column: breakpoint.column,
401+ column: breakpoint.column,
401− ..Default::default()
402+ ..Default::default()
402− });
403+ });
404+ }
403 }
405 }
404 "changed" => {
406 "changed" => {
405 for breakpoints in self.editor.breakpoints.values_mut() {
407 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) {
78 return;
78 return;
79 };
79 };
80
80
81− editor
82− .open(path, helix_view::editor::Action::Replace)
81+ if let Err(e) = editor.open(path, helix_view::editor::Action::Replace) {
83− .unwrap(); // TODO: there should be no unwrapping!
82+ editor.set_error(format!("Unable to jump to stack frame: {}", e));
83+ return;
84+ }
84
85
85 let (view, doc) = current!(editor);
86 let (view, doc) = current!(editor);
86
87