diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index a828530376..c6f2ea11ad 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -204,7 +204,7 @@ impl EngineState { pub fn get_span_contents(&self, span: &Span) -> &[u8] { for (contents, start, finish) in &self.file_contents { - if span.start >= *start && span.start < *finish { + if span.start >= *start && span.start <= *finish { return &contents[(span.start - start)..(span.end - start)]; } } @@ -550,7 +550,7 @@ impl<'a> StateWorkingSet<'a> { let permanent_end = self.permanent_state.next_span_start(); if permanent_end <= span.start { for (contents, start, finish) in &self.delta.file_contents { - if (span.start >= *start) && (span.start < *finish) { + if (span.start >= *start) && (span.start <= *finish) { return &contents[(span.start - permanent_end)..(span.end - permanent_end)]; } } diff --git a/src/main.rs b/src/main.rs index 9a2726c8af..eb724c347b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -195,8 +195,6 @@ fn main() -> Result<()> { continue; } - let mut engine_state = engine_state.clone(); - eval_source( &mut engine_state, &mut stack, @@ -304,7 +302,7 @@ fn eval_source( fname: &str, ) -> bool { let (block, delta) = { - let mut working_set = StateWorkingSet::new(&engine_state); + let mut working_set = StateWorkingSet::new(engine_state); let (output, err) = parse( &mut working_set, Some(fname), // format!("entry #{}", entry_num) @@ -320,17 +318,17 @@ fn eval_source( EngineState::merge_delta(engine_state, delta); - match eval_block(&engine_state, stack, &block, PipelineData::new()) { + match eval_block(engine_state, stack, &block, PipelineData::new()) { Ok(pipeline_data) => { - if let Err(err) = print_value(pipeline_data.into_value(), &engine_state) { - let working_set = StateWorkingSet::new(&engine_state); + if let Err(err) = print_value(pipeline_data.into_value(), engine_state) { + let working_set = StateWorkingSet::new(engine_state); report_error(&working_set, &err); return false; } } Err(err) => { - let working_set = StateWorkingSet::new(&engine_state); + let working_set = StateWorkingSet::new(engine_state); report_error(&working_set, &err); return false;