Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace fix tracking vector with boolean flag #1318

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions crates/lib-core/src/parser/segments/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ impl ErasedSegment {
}

let mut seg_buffer = Vec::new();
let mut fixes_applied = Vec::new();
let mut has_applied_fixes = false;
let mut _requires_validate = false;

for seg in self.segments() {
Expand All @@ -733,9 +733,10 @@ impl ErasedSegment {

let fixes_count = anchor_info.fixes.len();
for mut lint_fix in anchor_info.fixes {
has_applied_fixes = true;

// Deletes are easy.
if lint_fix.edit_type == EditType::Delete {
fixes_applied.push(lint_fix);
// We're just getting rid of this segment.
_requires_validate = true;
// NOTE: We don't add the segment in this case.
Expand Down Expand Up @@ -779,12 +780,10 @@ impl ErasedSegment {
if lint_fix.edit_type == EditType::CreateBefore {
seg_buffer.push(seg.clone());
}

fixes_applied.push(lint_fix);
}
}

if !fixes_applied.is_empty() {
if has_applied_fixes {
seg_buffer =
position_segments(&seg_buffer, self.get_position_marker().as_ref().unwrap());
}
Expand Down
Loading