diff --git a/crates/taplo-common/src/schema/mod.rs b/crates/taplo-common/src/schema/mod.rs index 2e18722d2..bd1218532 100644 --- a/crates/taplo-common/src/schema/mod.rs +++ b/crates/taplo-common/src/schema/mod.rs @@ -717,22 +717,24 @@ impl NodeValidationError { } pub fn text_ranges(&self) -> Box + '_> { - let include_children = match self.error.kind { - ValidationErrorKind::AdditionalProperties { .. } => false, - _ => true, - }; + match self.error.kind { + ValidationErrorKind::AdditionalProperties { .. } => { + let include_children = false; - if self.keys.is_empty() { - return Box::new(self.node.text_ranges(include_children).into_iter()); - } + if self.keys.is_empty() { + return Box::new(self.node.text_ranges(include_children).into_iter()); + } - Box::new( - self.keys - .clone() - .into_iter() - .map(move |key| self.node.get(key).text_ranges(include_children)) - .flatten(), - ) + Box::new( + self.keys + .clone() + .into_iter() + .map(move |key| self.node.get(key).text_ranges(include_children)) + .flatten(), + ) + } + _ => Box::new(self.node.text_ranges(true)), + } } }