mirror of
https://github.com/nushell/nushell.git
synced 2024-11-07 09:04:18 +01:00
fix --ide-ast when there are errors (#13737)
# Description This PR fixes #13732. However, I don't think it's a proper fix. 1. It doesn't really show what the problem is. 2. It kind of side-steps the error entirely. I do think the change in span.rs may be valid because I don't think span.end should ever be 0. In the example in 13732 the span end was always 0 and so that made contains_span() return true, which seems like a false positive. The `checked_sub()` in ide.rs kind of just stops it from failing outloud. I'll leave it to smarter folks than me to land this if they think it's worthy.
This commit is contained in:
parent
92091599ff
commit
b2cab3274b
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user