From 6709c75fec92b6a202b782d243624f8ac6491237 Mon Sep 17 00:00:00 2001 From: Brad Larsen Date: Wed, 20 Nov 2024 11:26:50 -0500 Subject: [PATCH] Fix location comment --- crates/noseyparker/src/location.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/noseyparker/src/location.rs b/crates/noseyparker/src/location.rs index 8df671bfd..03aba43db 100644 --- a/crates/noseyparker/src/location.rs +++ b/crates/noseyparker/src/location.rs @@ -148,8 +148,10 @@ impl LocationMapping { /// Panics if the given `OffsetSpan` is not valid for this `LocationMapping`. pub fn get_source_span(&self, span: &OffsetSpan) -> SourceSpan { let start = self.offset_to_source[span.start]; - let end = self.offset_to_source[span.end.saturating_sub(1)]; // XXX: is this right? - // let end = self.offset_to_source[span.end]; + let end_idx = span.end.saturating_sub(1); + + // FIXME: The end index is not calculated correctly here! It currently includes the line terminator + let end = self.offset_to_source[end_idx]; SourceSpan { start, end } } }