Skip to content

Commit

Permalink
fix incorrect error locations (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
usamoi authored Oct 4, 2024
1 parent 6694969 commit 461151d
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions crates/taplo-common/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,22 +717,24 @@ impl NodeValidationError {
}

pub fn text_ranges(&self) -> Box<dyn Iterator<Item = TextRange> + '_> {
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)),
}
}
}

Expand Down

0 comments on commit 461151d

Please sign in to comment.