From 9b378afb624c578d38bb81fc25190900865b0c39 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 4 Apr 2024 10:28:31 -0400 Subject: [PATCH] Add a serializer for the jump alphabet config option (#10156) Without a serializer, we drop the custom alphabet when making config modifications like with `:set`. For example before this commit, `:set mouse false` would reset a custom alphabet to the default. --- helix-view/src/editor.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index dd360a78ebdd..d7058d3ef022 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -212,6 +212,14 @@ impl Default for FilePickerConfig { } } +fn serialize_alphabet(alphabet: &[char], serializer: S) -> Result +where + S: Serializer, +{ + let alphabet: String = alphabet.iter().collect(); + serializer.serialize_str(&alphabet) +} + fn deserialize_alphabet<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, @@ -323,7 +331,10 @@ pub struct Config { #[serde(default)] pub indent_heuristic: IndentationHeuristic, /// labels characters used in jumpmode - #[serde(skip_serializing, deserialize_with = "deserialize_alphabet")] + #[serde( + serialize_with = "serialize_alphabet", + deserialize_with = "deserialize_alphabet" + )] pub jump_label_alphabet: Vec, }