Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 authored Jul 12, 2024
1 parent 6531fca commit adb33e8
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions crates/core/src/inline_snippets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,26 +350,28 @@ fn delete_hanging_comma(
.collect();

// Flag to track if the last character was a comma
let mut previous_char_was_comma = false;
let mut last_was_comma = false;

for (index, c) in chars {
if Some(&index) != next_comma {
next_comma = to_delete.next();
previous_char_was_comma = false;
continue;
}
if c == ',' {
if previous_char_was_comma {
if c == ',' && last_was_comma {
continue;
}
previous_char_was_comma = true;
result.push(c);
last_was_comma = c == ',';
} else {
// Keep track of ranges we need to expand into, since we deleted code in the range
// This isn't perfect, but it's good enough for tracking cell boundaries
previous_char_was_comma = false;

for (range, ..) in replacement_ranges.iter_mut().rev() {
if range.end >= index {
range.end += 1;
break;
}
}
result.push(c);
ranges_updates = update_range_shifts(index + offset, &ranges_updates, &ranges);
next_comma = to_delete.next();
last_was_comma = false;
}
}

for (r, u) in replacements.iter_mut().zip(ranges_updates) {
Expand Down

0 comments on commit adb33e8

Please sign in to comment.