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.
pull/10159/head
Michael Davis 8 months ago committed by GitHub
parent 5fece0054d
commit 1539312558
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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> fn deserialize_alphabet<'de, D>(deserializer: D) -> Result<Vec<char>, D::Error>
where where
D: Deserializer<'de>, D: Deserializer<'de>,
@ -323,7 +331,10 @@ pub struct Config {
#[serde(default)] #[serde(default)]
pub indent_heuristic: IndentationHeuristic, pub indent_heuristic: IndentationHeuristic,
/// labels characters used in jumpmode /// 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>, pub jump_label_alphabet: Vec<char>,
} }

Loading…
Cancel
Save