Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ lazy_static = "1.5.0"
log = "0.4.27"
markdown = "1.0.0"
memchr = "2.7.5"
miette = { package = "oxc-miette", version = "2.3.2", features = ["fancy-no-syscall"] }
miette = { package = "oxc-miette", version = "2.4.0", features = ["fancy-no-syscall"] }
mimalloc-safe = "0.1.54"
nonmax = "0.5.5"
num-bigint = "0.4.6"
Expand Down
29 changes: 29 additions & 0 deletions crates/oxc_linter/src/fixer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,35 @@ impl<'a> Message<'a> {
};
Self { error, span: Span::new(start, end), fixes, fixed: false }
}

/// move the offset of all spans to the right
pub fn move_offset(&mut self, offset: u32) -> &mut Self {
if offset == 0 {
return self;
}

self.span = self.span.move_right(offset);

if let Some(labels) = &mut self.error.labels {
for label in labels {
label.set_span_offset(label.offset().saturating_add(offset as usize));
}
}

match &mut self.fixes {
PossibleFixes::None => {}
PossibleFixes::Single(fix) => {
fix.span = fix.span.move_right(offset);
}
PossibleFixes::Multiple(fixes) => {
for fix in fixes {
fix.span = fix.span.move_right(offset);
}
}
}

self
}
}

impl From<Message<'_>> for OxcDiagnostic {
Expand Down
7 changes: 6 additions & 1 deletion crates/oxc_linter/src/service/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,12 @@ impl Runtime {
.collect(),
}
.into_iter()
.map(|message| message.clone_in(allocator)),
.map(|mut message| {
if section.source.start != 0 {
message.move_offset(section.source.start);
}
message.clone_in(allocator)
}),
);
}
},
Expand Down
Loading