summaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-06-20 20:47:48 +0000
committerBlaž Hrastnik2022-06-21 17:26:24 +0000
commit23b5b1e25aca1dbed87fef18cc72b16852ba40a8 (patch)
tree21534a9c7ed846a51732b8cba59321e8ffdb8dac /helix-term/src/commands
parent19dccade7c44619bfa414a711fe72a612e4ca358 (diff)
Remove a couple more unwraps
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r--helix-term/src/commands/lsp.rs11
-rw-r--r--helix-term/src/commands/typed.rs6
2 files changed, 13 insertions, 4 deletions
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index b8c5e5d1..6f75fb49 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -61,7 +61,14 @@ fn jump_to_location(
return;
}
};
- let _id = editor.open(&path, action).expect("editor.open failed");
+ match editor.open(&path, action) {
+ Ok(_) => (),
+ Err(err) => {
+ let err = format!("failed to open path: {:?}: {:?}", location.uri, err);
+ editor.set_error(err);
+ return;
+ }
+ }
let (view, doc) = current!(editor);
let definition_pos = location.range.start;
// TODO: convert inside server
@@ -491,7 +498,7 @@ fn goto_impl(
locations: Vec<lsp::Location>,
offset_encoding: OffsetEncoding,
) {
- let cwdir = std::env::current_dir().expect("couldn't determine current directory");
+ let cwdir = std::env::current_dir().unwrap_or_default();
match locations.as_slice() {
[location] => {
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 19c6a5dc..70f5fa9f 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -1,3 +1,5 @@
+use std::ops::Deref;
+
use super::*;
use helix_view::editor::{Action, ConfigEvent};
@@ -961,7 +963,7 @@ fn get_option(
let key = &args[0].to_lowercase();
let key_error = || anyhow::anyhow!("Unknown key `{}`", key);
- let config = serde_json::to_value(&cx.editor.config().clone()).unwrap();
+ let config = serde_json::json!(cx.editor.config().deref());
let pointer = format!("/{}", key.replace('.', "/"));
let value = config.pointer(&pointer).ok_or_else(key_error)?;
@@ -984,7 +986,7 @@ fn set_option(
let key_error = || anyhow::anyhow!("Unknown key `{}`", key);
let field_error = |_| anyhow::anyhow!("Could not parse field `{}`", arg);
- let mut config = serde_json::to_value(&cx.editor.config().clone()).unwrap();
+ let mut config = serde_json::json!(&cx.editor.config().deref());
let pointer = format!("/{}", key.replace('.', "/"));
let value = config.pointer_mut(&pointer).ok_or_else(key_error)?;