summaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-12-02 01:20:19 +0000
committerBlaž Hrastnik2021-12-02 01:20:19 +0000
commit573cb399261f9ab8f799dcf82a40220dcc6539e4 (patch)
tree4143d0a1bcef72baa2979e6185633e5abb69752c /helix-term/src
parentffc89e483be1bc0cc20cdd19eb38dec6bf421c1a (diff)
dap: Remove some unwraps
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/application.rs26
-rw-r--r--helix-term/src/commands/dap.rs7
2 files changed, 18 insertions, 15 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 3d6d00fe..b6753ec5 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -388,18 +388,20 @@ impl Application {
}
Event::Breakpoint(events::Breakpoint { reason, breakpoint }) => match &reason[..] {
"new" => {
- self.editor
- .breakpoints
- .entry(breakpoint.source.unwrap().path.unwrap()) // TODO: no unwraps
- .or_default()
- .push(Breakpoint {
- id: breakpoint.id,
- verified: breakpoint.verified,
- message: breakpoint.message,
- line: breakpoint.line.unwrap().saturating_sub(1), // TODO: no unwrap
- column: breakpoint.column,
- ..Default::default()
- });
+ if let Some(source) = breakpoint.source {
+ self.editor
+ .breakpoints
+ .entry(source.path.unwrap()) // TODO: no unwraps
+ .or_default()
+ .push(Breakpoint {
+ id: breakpoint.id,
+ verified: breakpoint.verified,
+ message: breakpoint.message,
+ line: breakpoint.line.unwrap().saturating_sub(1), // TODO: no unwrap
+ column: breakpoint.column,
+ ..Default::default()
+ });
+ }
}
"changed" => {
for breakpoints in self.editor.breakpoints.values_mut() {
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index 1cb5a35a..00305fe2 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -78,9 +78,10 @@ pub fn jump_to_stack_frame(editor: &mut Editor, frame: &helix_dap::StackFrame) {
return;
};
- editor
- .open(path, helix_view::editor::Action::Replace)
- .unwrap(); // TODO: there should be no unwrapping!
+ if let Err(e) = editor.open(path, helix_view::editor::Action::Replace) {
+ editor.set_error(format!("Unable to jump to stack frame: {}", e));
+ return;
+ }
let (view, doc) = current!(editor);