aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/config.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs
index cc4e7eee..a6d67b4a 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -398,7 +398,7 @@ pub struct Config {
tabspaces: usize,
/// How much scrolling history to keep
- #[serde(default="default_scroll_history", deserialize_with="failure_default")]
+ #[serde(default="default_scroll_history", deserialize_with="deserialize_scroll_history")]
scroll_history: u32,
}
@@ -406,6 +406,18 @@ fn default_scroll_history() -> u32 {
10_000
}
+fn deserialize_scroll_history<'a, D>(deserializer: D) -> ::std::result::Result<u32, D::Error>
+ where D: de::Deserializer<'a>
+{
+ match u32::deserialize(deserializer) {
+ Ok(lines) => Ok(lines),
+ Err(err) => {
+ eprintln!("problem with config: {}; Using default value", err);
+ Ok(default_scroll_history())
+ },
+ }
+}
+
fn failure_default_vec<'a, D, T>(deserializer: D) -> ::std::result::Result<Vec<T>, D::Error>
where D: de::Deserializer<'a>,
T: Deserialize<'a>