diff --git a/crates/nu-protocol/src/span.rs b/crates/nu-protocol/src/span.rs index cb6d96421c..9fe42c2530 100644 --- a/crates/nu-protocol/src/span.rs +++ b/crates/nu-protocol/src/span.rs @@ -130,7 +130,7 @@ impl Span { } pub fn contains_span(&self, span: Self) -> bool { - self.start <= span.start && span.end <= self.end + self.start <= span.start && span.end <= self.end && span.end != 0 } /// Point to the space just past this span, useful for missing values diff --git a/src/ide.rs b/src/ide.rs index a08e7afcdf..948539d839 100644 --- a/src/ide.rs +++ b/src/ide.rs @@ -642,8 +642,8 @@ pub fn ast(engine_state: &mut EngineState, file_path: &str) { { "type": "ast", "span": { - "start": span.start - offset, - "end": span.end - offset, + "start": span.start.checked_sub(offset), + "end": span.end.checked_sub(offset), }, "shape": shape.to_string(), "content": content // may not be necessary, but helpful for debugging