Skip to content

Commit

Permalink
fix: never panic on function input
Browse files Browse the repository at this point in the history
  • Loading branch information
myypo committed Aug 24, 2024
1 parent 969e1fb commit e057563
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Default configuration:
relative_goto = 50,
absolute_goto = 100,
},
-- Interactions that happen earlier than the cooldown won't be taken into accont when calculating marks' weights
-- Interactions that happen earlier than the cooldown won't be taken into account when calculating marks' weights
cooldown_seconds = 60,
},
}
Expand Down
12 changes: 11 additions & 1 deletion macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ pub fn derive_deserializing_from_lua(input: TokenStream) -> TokenStream {
impl nvim_oxi::conversion::FromObject for #ident {
fn from_object(obj: nvim_oxi::Object) -> core::result::Result<Self, nvim_oxi::conversion::Error> {
use serde::Deserialize;
Self::deserialize(nvim_oxi::serde::Deserializer::new(obj)).map_err(Into::into)
Ok(match Self::deserialize(nvim_oxi::serde::Deserializer::new(obj)).map_err(nvim_oxi::conversion::Error::from) {
Ok(v) => v,
Err(e) => {
let _ = nvim_oxi::api::notify(
&format!("Bad compass function input: {}. Using defaults instead", e.to_string()),
nvim_oxi::api::types::LogLevel::Error,
&nvim_oxi::api::opts::NotifyOpts::builder().build(),
);
Self::default()
},
})
}
}

Expand Down

0 comments on commit e057563

Please sign in to comment.