in src/models/matches.rs [238:260]
fn is_comma_safe_to_delete(&self, comma: &Node, code: &str, trailing: bool) -> bool {
if !self.is_comma(code, comma) {
return false;
}
let (start_range, end_range) = self.get_first_and_last_associated_ranges();
if trailing {
if let Some(prev_node) = comma.prev_sibling() {
// Ensure that the previous node's end byte is not beyond the deleted node's end byte
if prev_node.end_byte() > end_range.end_byte {
return false;
}
}
} else if let Some(next_node) = comma.next_sibling() {
// Ensure that the next node's start byte is not before the deleted node's start byte
if next_node.start_byte() < start_range.start_byte {
return false;
}
}
// It is safe to delete the comma node
true
}