aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-03-09 17:57:24 +0100
committerJoe Wilm <joe@jwilm.com>2018-06-02 09:36:27 -0700
commit04086186a00d50f22a7e1914d89a8dd1beb695cc (patch)
tree892134b9a5241c5601a68abbf920852bb01323d5 /src
parentdd60ea563d1b3022e387d96e2b6cf8bbb682b947 (diff)
downloadalacritty-04086186a00d50f22a7e1914d89a8dd1beb695cc.tar.gz
alacritty-04086186a00d50f22a7e1914d89a8dd1beb695cc.zip
Provide correct default for scroll_history
When implementing fallback to the default value with an u32 you will get 0 as the default value. However the default scrollback value is 10_000. A custom deserializer has been implemented which automatically falls back to the correct default value.
Diffstat (limited to 'src')
-rw-r--r--src/config.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs
index 2c2cfe46..d49dd3b4 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>