aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/syntax.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index c2dd3310..2a5bb974 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -48,6 +48,21 @@ where
.transpose()
}
+fn deserialize_tab_width<'de, D>(deserializer: D) -> Result<usize, D::Error>
+where
+ D: serde::Deserializer<'de>,
+{
+ usize::deserialize(deserializer).and_then(|n| {
+ if n > 0 && n <= 16 {
+ Ok(n)
+ } else {
+ Err(serde::de::Error::custom(
+ "tab width must be a value from 1 to 16 inclusive",
+ ))
+ }
+ })
+}
+
pub fn deserialize_auto_pairs<'de, D>(deserializer: D) -> Result<Option<AutoPairs>, D::Error>
where
D: serde::Deserializer<'de>,
@@ -424,6 +439,7 @@ pub struct DebuggerQuirks {
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct IndentationConfiguration {
+ #[serde(deserialize_with = "deserialize_tab_width")]
pub tab_width: usize,
pub unit: String,
}