From 20f319860908c2fa86bba25bb1e7bf8ba1a464e1 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 3 Feb 2019 16:44:39 +0000 Subject: Fix regression in the URL launcher config Due to the merging of configuration files on all platforms, it has been made impossible to completely disable URL launching without still executing some kind of program like `true`. Setting the launcher to `None` in the config, will now disable it completely. This fixes #2058. --- CHANGELOG.md | 3 ++- alacritty.yml | 2 ++ src/config/mod.rs | 30 +++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d2a4e65..731a60e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Smoother scrolling for touchpads (also affects scrolling with some mice that send fractional scrolling values) +- Improve scrolling accuracy with devices sending fractional updates (like touchpads) - `scrolling.multiplier` now affects normal scrolling with touchpads ### Fixed @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Excessive polling every 100ms with `live_config_reload` enabled - Unicode characters at the beginning of URLs are now properly ignored - Remove error message when reloading an empty config +- Allow disabling URL launching by setting the value of `mouse.url.launcher` to `None` ## Version 0.2.7 diff --git a/alacritty.yml b/alacritty.yml index 5cf58d25..07120b7a 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -291,6 +291,8 @@ mouse: # This program is executed when clicking on a text which is recognized as a URL. # The URL is always added to the command as the last parameter. # + # When set to `None`, URL launching will be disabled completely. + # # Default: # - (macOS) open # - (Linux) xdg-open diff --git a/src/config/mod.rs b/src/config/mod.rs index d9717704..c487ceb7 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -116,7 +116,7 @@ pub struct Mouse { #[derive(Clone, Debug, Deserialize, PartialEq, Eq)] pub struct Url { // Program for opening links - #[serde(deserialize_with = "failure_default")] + #[serde(deserialize_with = "deserialize_launcher")] pub launcher: Option, // Modifier used to open links @@ -124,6 +124,34 @@ pub struct Url { pub modifiers: ModifiersState, } +fn deserialize_launcher<'a, D>(deserializer: D) -> ::std::result::Result, D::Error> + where D: de::Deserializer<'a> +{ + let default = Url::default().launcher; + + // Deserialize to generic value + let val = match serde_yaml::Value::deserialize(deserializer) { + Ok(val) => val, + Err(err) => { + error!("Problem with config: {}; using {}", err, default.clone().unwrap().program()); + return Ok(default); + }, + }; + + // Accept `None` to disable the launcher + if val.as_str().filter(|v| v.to_lowercase() == "none").is_some() { + return Ok(None); + } + + match >::deserialize(val) { + Ok(launcher) => Ok(launcher), + Err(err) => { + error!("Problem with config: {}; using {}", err, default.clone().unwrap().program()); + Ok(default) + }, + } +} + impl Default for Url { fn default() -> Url { Url { -- cgit