diff --git a/crates/nu-parser/src/parse_keywords.rs b/crates/nu-parser/src/parse_keywords.rs index 3ebf61bbd..e145d4cd9 100644 --- a/crates/nu-parser/src/parse_keywords.rs +++ b/crates/nu-parser/src/parse_keywords.rs @@ -218,8 +218,6 @@ pub fn parse_alias( let replacement = spans[3..].to_vec(); - //println!("{:?} {:?}", alias_name, replacement); - working_set.add_alias(alias_name, replacement); } @@ -311,15 +309,15 @@ pub fn parse_export( pub fn parse_module_block( working_set: &mut StateWorkingSet, - spans: &[Span], + span: Span, ) -> (Block, Option) { let mut error = None; working_set.enter_scope(); - let source = working_set.get_span_contents(spans[0]); + let source = working_set.get_span_contents(span); - let (output, err) = lex(source, spans[0].start, &[], &[]); + let (output, err) = lex(source, span.start, &[], &[]); error = error.or(err); let (output, err) = lite_parse(&output); @@ -380,8 +378,8 @@ pub fn parse_module_block( stmt } else { - error = Some(ParseError::Expected("not a pipeline".into(), spans[0])); - garbage_statement(spans) + error = Some(ParseError::Expected("not a pipeline".into(), span)); + garbage_statement(&[span]) } }) .into(); @@ -441,7 +439,7 @@ pub fn parse_module( let block_span = Span { start, end }; - let (block, err) = parse_module_block(working_set, &[block_span]); + let (block, err) = parse_module_block(working_set, block_span); error = error.or(err); let block_id = working_set.add_module(&module_name, block); @@ -530,7 +528,7 @@ pub fn parse_use( let span_end = working_set.next_span_start(); let (block, err) = - parse_module_block(working_set, &[Span::new(span_start, span_end)]); + parse_module_block(working_set, Span::new(span_start, span_end)); error = error.or(err); let block_id = working_set.add_module(&module_name, block); diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index de240af11..1f8de20c9 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -501,7 +501,7 @@ impl<'a> StateWorkingSet<'a> { let permanent_span_start = self.permanent_state.next_span_start(); if let Some((_, _, last)) = self.delta.file_contents.last() { - permanent_span_start + *last + *last } else { permanent_span_start } @@ -561,7 +561,7 @@ impl<'a> StateWorkingSet<'a> { if permanent_end <= span.start { for (contents, start, finish) in &self.delta.file_contents { if (span.start >= *start) && (span.end <= *finish) { - return &contents[(span.start - permanent_end)..(span.end - permanent_end)]; + return &contents[(span.start - start)..(span.end - start)]; } } } else {