Skip to content

Commit

Permalink
restore cursor shape when exits
Browse files Browse the repository at this point in the history
  • Loading branch information
nibon7 committed May 29, 2023
1 parent cc04b9a commit 2ee0c75
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion crates/nu-cli/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use nu_color_config::StyleComputer;
use nu_command::hook::eval_hook;
use nu_command::util::get_guaranteed_cwd;
use nu_engine::convert_env_values;
use nu_parser::{lex, trim_quotes_str};
use nu_parser::{lex, parse, trim_quotes_str};
use nu_protocol::{
config::NuCursorShape,
engine::{EngineState, Stack, StateWorkingSet},
Expand Down Expand Up @@ -586,6 +586,27 @@ pub fn evaluate_repl(
} else if !s.trim().is_empty() {
trace!("eval source: {}", s);

let mut cmds = s.split_whitespace();
if let Some("exit") = cmds.next() {
let mut working_set = StateWorkingSet::new(engine_state);
let _ = parse(&mut working_set, None, s.as_bytes(), false);

if working_set.parse_errors.is_empty() {
match cmds.next() {
Some(s) => {
if let Ok(n) = s.parse::<i32>() {
drop(line_editor);
std::process::exit(n);
}
}
None => {
drop(line_editor);
std::process::exit(0);
}
}
}
}

eval_source(
engine_state,
stack,
Expand Down

0 comments on commit 2ee0c75

Please sign in to comment.