mirror of
https://github.com/nushell/nushell
synced 2024-12-28 22:13:10 +00:00
WIP
This commit is contained in:
parent
b5965ee8ef
commit
baac60a5a7
2 changed files with 7 additions and 9 deletions
|
@ -204,7 +204,7 @@ impl EngineState {
|
||||||
|
|
||||||
pub fn get_span_contents(&self, span: &Span) -> &[u8] {
|
pub fn get_span_contents(&self, span: &Span) -> &[u8] {
|
||||||
for (contents, start, finish) in &self.file_contents {
|
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)];
|
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();
|
let permanent_end = self.permanent_state.next_span_start();
|
||||||
if permanent_end <= span.start {
|
if permanent_end <= span.start {
|
||||||
for (contents, start, finish) in &self.delta.file_contents {
|
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)];
|
return &contents[(span.start - permanent_end)..(span.end - permanent_end)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -195,8 +195,6 @@ fn main() -> Result<()> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut engine_state = engine_state.clone();
|
|
||||||
|
|
||||||
eval_source(
|
eval_source(
|
||||||
&mut engine_state,
|
&mut engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
|
@ -304,7 +302,7 @@ fn eval_source(
|
||||||
fname: &str,
|
fname: &str,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let (block, delta) = {
|
let (block, delta) = {
|
||||||
let mut working_set = StateWorkingSet::new(&engine_state);
|
let mut working_set = StateWorkingSet::new(engine_state);
|
||||||
let (output, err) = parse(
|
let (output, err) = parse(
|
||||||
&mut working_set,
|
&mut working_set,
|
||||||
Some(fname), // format!("entry #{}", entry_num)
|
Some(fname), // format!("entry #{}", entry_num)
|
||||||
|
@ -320,17 +318,17 @@ fn eval_source(
|
||||||
|
|
||||||
EngineState::merge_delta(engine_state, delta);
|
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) => {
|
Ok(pipeline_data) => {
|
||||||
if let Err(err) = print_value(pipeline_data.into_value(), &engine_state) {
|
if let Err(err) = print_value(pipeline_data.into_value(), engine_state) {
|
||||||
let working_set = StateWorkingSet::new(&engine_state);
|
let working_set = StateWorkingSet::new(engine_state);
|
||||||
|
|
||||||
report_error(&working_set, &err);
|
report_error(&working_set, &err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let working_set = StateWorkingSet::new(&engine_state);
|
let working_set = StateWorkingSet::new(engine_state);
|
||||||
|
|
||||||
report_error(&working_set, &err);
|
report_error(&working_set, &err);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue