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.
This commit is contained in:
Michael Davis 2024-04-04 10:28:31 -04:00 committed by GitHub
parent 5fece0054d
commit 1539312558
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -212,6 +212,14 @@ impl Default for FilePickerConfig {
}
}
fn serialize_alphabet<S>(alphabet: &[char], serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let alphabet: String = alphabet.iter().collect();
serializer.serialize_str(&alphabet)
}
fn deserialize_alphabet<'de, D>(deserializer: D) -> Result<Vec<char>, 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<char>,
}