Repository: alacritty/alacritty (language: rust)

Issue:
Mouse bindings with numbers don't work as of 0.13
I upgraded to 0.13, ran `migrate` and am greeted with an error message:

```
[521.148322971s] [ERROR] [alacritty_config_derive] Config error: invalid type: integer `9`, expected Left, Right, Middle, Back, Forward, or a number from 0 to 65536
                                                   in `mouse`
                                                   ; ignoring binding
```


This is my binding:
```
[[mouse.bindings]]
action = "DecreaseFontSize"
mods = "Control"
mouse = 8
```

I narrowed the problem down to the deserializer which "only" contains `visit_str` and `visit_u64`

https://github.com/alacritty/alacritty/blob/659550ee34fe1b45ea176b88e60901d277d210a3/alacritty/src/config/bindings.rs#L849-L890

I'm just going to assume that this worked with `serde_json` (which I assume was used before) but for toml the numbers seem to be interpreted as signed by default.

Implementing a `visit_i64` method makes this work:

```rust
            fn visit_i64<E>(self, value: i64) -> Result<MouseButtonWrapper, E>
            where
                E: de::Error,
            {
                match value {
                    0..=65536 => Ok(MouseButtonWrapper(MouseButton::Other(value as u16))),
                    _ => Err(E::invalid_value(Unexpected::Signed(value), &self)),
                }
            }
```

I can submit a PR if this is an acceptable solution.

### System

OS: Linux (Arch)
Version: alacritty 0.13.0 (78fa4d6f)
Linux/BSD: X11/bspwm


Discussion / hints:
yeah, visit i64 should be fine.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f988f21dd40..49dddcce206 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Blurry window when using `window.dimensions` on some Wayland compositors
 - IME input lagging behind on X11
 - xdotool modifiers input not working correctly on X11
+- Parsing numbers fails for mouse bindings
 
 ## 0.13.0
 
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs
index b75676a33bf..f58744e56de 100644
--- a/alacritty/src/config/bindings.rs
+++ b/alacritty/src/config/bindings.rs
@@ -860,6 +860,16 @@ impl<'a> Deserialize<'a> for MouseButtonWrapper {
                 f.write_str("Left, Right, Middle, Back, Forward, or a number from 0 to 65536")
             }
 
+            fn visit_i64<E>(self, value: i64) -> Result<MouseButtonWrapper, E>
+            where
+                E: de::Error,
+            {
+                match value {
+                    0..=65536 => Ok(MouseButtonWrapper(MouseButton::Other(value as u16))),
+                    _ => Err(E::invalid_value(Unexpected::Signed(value), &self)),
+                }
+            }
+
             fn visit_u64<E>(self, value: u64) -> Result<MouseButtonWrapper, E>
             where
                 E: de::Error,


Test patch: