Skip to content

Commit

Permalink
Add a serializer for the jump alphabet config option (helix-editor#10156
Browse files Browse the repository at this point in the history
)

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.
  • Loading branch information
the-mikedavis authored and Vulpesx committed Jun 7, 2024
1 parent 6c0da5a commit 9b378af
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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>,
}

Expand Down

0 comments on commit 9b378af

Please sign in to comment.